a few MC++ / (Plain C++ really) questions about constructor & exception

L

Lloyd Dupont

- if I use the default new operator, are all the instance variable
initialize to NULL / 0 ?
- if there is not enough memory what happend with new ? does it return NULL
or throw an exception?
- if new throw a native C++ exception what happen in Managed C++ ?!
- if there is an exception in a construtor, is ~MyClass() called?
- if I want to throw an exception in a constructor should I free all native
type before? or should I throw and let the destructor (which check nullity
before deleting) do its job?
 
W

William DePalo [MVP VC++]

Lloyd Dupont said:
- if I use the default new operator, are all the instance variable
initialize to NULL / 0 ?
- if there is not enough memory what happend with new ? does it return
NULL or throw an exception?
- if new throw a native C++ exception what happen in Managed C++ ?!
- if there is an exception in a construtor, is ~MyClass() called?
- if I want to throw an exception in a constructor should I free all
native type before? or should I throw and let the destructor (which check
nullity before deleting) do its job?

I suggest that you post again in

microsoft.public.dotnet.languages.vc

Regards,
Will
 
L

Lloyd Dupont

William DePalo said:
I suggest that you post again in

microsoft.public.dotnet.languages.vc
That's a good idea!
I didn't though of that as I don't usually do C++ programing....
But in some case, surprisingly, Managed C++ is much leaner...
 
W

William DePalo [MVP VC++]

Lloyd Dupont said:
But in some case, surprisingly, Managed C++ is much leaner...

It really excels when you need to make use of both managed and native
classes in the same module or executable by providing the "it just works"
capability as well as Platform/Invoke available to all the other languages.

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top