In MS compiler system, you have some compiler
directive called novtable that allows to do what u r
saying - get rid of the global vtables from the
memory.
One uses it something like this :
class __declspec(novtable) foo
{
public:
virtual void funtion() = 0;
};
No match for that in GCC though! Any comments/inputs
welcome from gnu guys.
-Viren
==============
Hi,
Are there any hidden costs to using virtual functions
in C++ classes using
the PRC tools? (I know about the GCC compiler and
linker switches to disable
exceptions and RTTI.)
I know that polymorphism requires an in-memory table
to ensure that the
correct functions get called at run-time (late
binding) and that this eats
into the available heap size. However, I want to use
pure virtual functions
in my classes solely to specify a contract that
subclasses must abide to. I
will not use base class pointers, only pointers to
non-abstract classes.
Example:
-----------------------------------------------
class BaseClass {
protected:
int a;
public:
virtual void add(int a) = 0; // Pure virtual
function
};
class DerivedClass: public BaseClass {
public:
DerivedClass(int a) {
this->a = a;
}
void add(int a); // Implementation omitted
};
BaseClass* a = new DerivedClass(1);
a->add(1); // Polymorphism, late binding
DerivedClass* b = new DerivedClass(1);
b->add(1); // No polymorphism(?), early binding(?)
-----------------------------------------------
I have a gut feeling that the GCC compiler is smart
enough to resolve the
function call for "b" at compile-time, hence no need
for a function table at
run-time, but I'm not sure. (It's been years since I
last used C/C++ for a
large project.)
Also, how much memory does polymorphism actually
require? Should you really
avoid it at all costs on Palm OS? My target is OS 3.5+
running on 4Mb+
devices.
Thanks
-Laurens
=====
"There is nothing good or bad,
There is nothing happy or sad,
Only thinking makes it so!"
- William Shakespeare
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/