I've created a new header file in which one will find :
#using <mscorlib.dll>
using namespace System;
__gc class G
{
public:
int k;
int sum(int){return 0;}
};
a really basic managed class.
In the same header file is a normal C++ class definition
class Temp1
{
public:
Temp1(){G *g=new G;}
~Temp1();
};
Now in some old code I have tried
G *g=new G; //fail
Temp1 t; //ok - works as a wrapper class
error C3828: 'G': placement arguments not allowed while creating
instances of managed classes
So why does my wrapper class work in declaring a managed class object
whilst creating it directly cause a compiler error???
Cheers
Ioannis Vranos - 25 Nov 2004 13:20 GMT
> I've created a new header file in which one will find :
>
[quoted text clipped - 27 lines]
> error C3828: 'G': placement arguments not allowed while creating
> instances of managed classes
I do not know what you mean, the code:
__gc class G
{
public:
int k;
int sum(int){return 0;}
};
int main()
{
G *g=new G;
}
compiles OK here.

Signature
Ioannis Vranos
Ronald Laeremans [MSFT] - 30 Nov 2004 01:16 GMT
You probably have included an MFC header or some other header that defines
new for you, like in the MFC case to DEBUG_NEW that uses placement syntax to
help debug memory leaks.
You could build a preprocessed file to verify what is happening.
Ronald Laeremans
Visual C++ team
> I've created a new header file in which one will find :
>
[quoted text clipped - 32 lines]
>
> Cheers