Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Non-Virtual Destructors...

Status
Not open for further replies.

Nosferatu

Programmer
Jun 9, 2000
412
0
0
RO
Consider the following statament:
{Statament}
The only thing that one has to take into consideration when using non-virtual constructors is when deleting an object possibly upcasted to a base class (or some lower level ancestor).
{Eos}
In this case, the destructor of the class type known at the invocation moment of the delete operator is called instead of the destructor of the actuall class the object represents.

Am i right, wrong or there is something more about this issue?
Does the VTable get store (or at least pointers to functions) in each object created? If not, how the compiler knows to call the appropriate functions at runtime? By RTTI?

I am concerned about this because i want to make some objects really small since they are prone to memory "eating", depending on the input of my program, so i would strip all possibly parts of my objects i can find unnecessary.

Thanks! [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Hmmm, am not sure.
Can the destrcutor of the derived class be called without making the virtual ? (maybe make the base class destructor).

Am concerned too.

Srik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top