Re: Type intializing with template

From: paul (psegaro_at_yahoo.com)
Date: 02/12/05


Date: 12 Feb 2005 05:55:19 -0800

Antti,

Thanks for the reply,

The actual code I was working on had the enclosing template declaration
for the constructor. While writing the simplified description of the
problem posted here, I forgot that detail.

ref class B {
private:
  static A<X,Y>^ a = gcnew A<X,Y>();
};

The above compiles ok in Visual c++ 2005. While the code below

ref class B {
private:
  static A<X,Y>^ a = gcnew A<X,Y>::A();
};

gives C2061: syntax error : identifier '{ctor}

When I tried to follow your advice of using the assignment operation
outside the class' scope, in file scope, I got "static data members of
managed types must be defined within the class definition" error.

Thanks again for I was able to resolve the issue thanks to your, Carl's
and Bo's feedback.

ptrue



Relevant Pages

  • Re: Generic class syntax help needed
    ... private ref class Command ... public void AddParameters(BerkeleyParameterkey, ... field is also a generic class which I've already got as the following: ... public ref class BerkeleyParameter ...
    (microsoft.public.dotnet.languages.vc)
  • RE: Generic class syntax help needed
    ... private ref class Command ... public void AddParameters(BerkeleyParameterkey, ... field is also a generic class which I've already got as the following: ... public ref class BerkeleyParameter ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Exporting a Type (Class) from a managed dll (assembly)
    ... In A.h header file If I change public to private ... cannot export the derived type with an assembly private base type 'A' ... In A.h header file When I change the private to public ... public ref class A; // not private ref class A; ...
    (microsoft.public.dotnet.languages.vc)
  • Re: releaseing unmanaged STL objects
    ... Admittedly the OP also isn't using ref class, ... > void Dispose() { ... > virtual void Finalize(){ ...
    (microsoft.public.dotnet.languages.csharp)