Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2004

Tip: Looking for answers? Try searching our database.

DotNet wannabe : Declaring MC++ class object in C ++ class - error ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zardoz - 25 Nov 2004 10:42 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.