A
alexander.stippler
Hi
I wonder if their will be a performance penalty in the following
situation due to virtual function calls:
class Interface
{
public:
virtual void methodA() = 0;
virtual void methodB() = 0;
virtual void methodC() = 0;
virtual void methodD() = 0;
};
class Implementation
{
public:
void methodA() { /* do someting */ }
void methodB() { /* do someting */ }
void methodC() { /* do someting */ }
void methodD() { /* do someting */ }
};
IMHO there is no need for class Implementation to have a virtual method
table, since there is just one possibility for every method. It's a
special case, I know. Other derived classes may have virtual functions.
What do current compilers do? Are there optimizations for such
situations or did I just miss something?
regards,
Alex
I wonder if their will be a performance penalty in the following
situation due to virtual function calls:
class Interface
{
public:
virtual void methodA() = 0;
virtual void methodB() = 0;
virtual void methodC() = 0;
virtual void methodD() = 0;
};
class Implementation
{
public:
void methodA() { /* do someting */ }
void methodB() { /* do someting */ }
void methodC() { /* do someting */ }
void methodD() { /* do someting */ }
};
IMHO there is no need for class Implementation to have a virtual method
table, since there is just one possibility for every method. It's a
special case, I know. Other derived classes may have virtual functions.
What do current compilers do? Are there optimizations for such
situations or did I just miss something?
regards,
Alex