Re: Virtual function call optimization
On Sep 26, 8:59 pm, "Kevin P. Fleming" <n...@kpfleming.us> wrote:
On 09/26/2011 09:38 AM, cppquester wrote:
Maybe it was not clear what I meant with effort:
If the effort is to organize a couple of platforms, install several
compilers, etc.
something in the order of many hours: Why not just ask instead?
Somebody might have done it already and is willing to share his
knowledge.
But that's not the question you asked: you didn't specify any platforms,
compilers or anything else. You asked a generic question about C++.
If you had said "I've tested this on Windows using Visual Studio 2010
and Ubuntu 11.04 using gcc 4.5.1, but I need to know if it will be
optimized on platforms X, Y and Z" the answers to your question would
have been very different.
Yes, it would have been: "Ask in a platform specific group" :-)
Which would have been ok, but I was expecting that it is clearly
defined (to use a regular function call).
Or at least a de facto standard.
But as at least on some platforms late binding is used I found a
solution (for all platforms):
class B
{
public:
virtual void foo() {}
};
class D: public B
{
public:
void foo() { fooD();}
void fooD() {}
};
int main(int argc, char *argv[])
{
D* d = new D();
d->fooD();
return 0;
}