My collection need to upgrade to dotnet. It is right in vc6, but is error in
vc7.net
following is code:
template <class ContainerType, class InterfaceType>
class InterfaceCopy
{
public :
typedef ContainerType::value_type SourceType;
static void init(InterfaceType** p)
{
_CopyInterface<InterfaceType>::init(p);
}
static void destroy(InterfaceType** p)
{
_CopyInterface<InterfaceType>::destroy(p);
}
static HRESULT copy(InterfaceType** pTo, SourceType* pFrom)
{
return _CopyInterface<InterfaceType>::copy(pTo, (&(pFrom->second)));
}
}; // class Interface Copy Policy
Change
typedef ContainerType::value_type SourceType;
to
typename ContainerType::value_type SourceType;
f:\VideoMonitor.ZHP\VideoSampleDevice\VideoSampleDevices.h(28) : error
C2061: syntax error: identifier ??SourceType??
....................
Thanks.
zhp80.Townee
Kim Gräsman - 22 Feb 2005 09:32 GMT
Hi zhp80.Townee,
> typename ContainerType::value_type SourceType;
>
> f:\VideoMonitor.ZHP\VideoSampleDevice\VideoSampleDevices.h(28) : error
> C2061: syntax error: identifier ¡°SourceType¡±
I don't think typename is legal here... Or it is, but it makes SourceType an instance of ContainerType::value_type. See
http://msdn.com/library/en-us/vclang/html/_langref_typename.asp
Of course, I'm no language expert, so it could be that I'm overlooking something, but I'd change it to a typedef if I were you.

Signature
Best regards,
Kim Gräsman
adebaene@club-internet.fr - 22 Feb 2005 09:38 GMT
<z...@sina.com> wrote:
> My collection need to upgrade to dotnet. It is right in vc6, but is error in
> vc7.net
[quoted text clipped - 27 lines]
> to
> typename ContainerType::value_type SourceType;
Use typedef typename ContainerType::value_type SourceType;
You're still defining a typedef (SourceType), but the definition of
this typedef is a dependent type, and therefore the compiler needs to
be told that ContainerType::value_type is a type.
Arnaud
MVP - VC