Programming, for all ages and all languages.
earlz
Member
Posts: 1546 Joined: Thu Jul 07, 2005 11:00 pm
Contact:
Post
by earlz » Sun Jul 01, 2007 11:27 am
I know virtual functions add overhead, but for the highest level of an inheritance tree, will it add any overhead?
like would
Code: Select all
class base{
virtual bah();
};
class up1: base{
virtual bah();
};
class up2: base{
virtual bah();
};
void main(base* low, up1* up){
low->bah(); //I know this will produce overhead
up->bah(); //but will this!?
}
Candy
Member
Posts: 3882 Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven
Post
by Candy » Sun Jul 01, 2007 12:42 pm
Code: Select all
class base{
virtual bah();
};
class up1: base{
virtual bah();
};
class up2: base{
virtual bah();
};
void func(base* low, up1* up){
low->bah(); //I know this will produce overhead
up->bah(); //but will this!?
}
class up3 : pubilc up1 { virtual bah(); };
int main() {
func(new low(), new up3());
}
If it didn't, the addition would fail to work.
Please don't modify main's signature - it was fine & dandy with argc and argv.
earlz
Member
Posts: 1546 Joined: Thu Jul 07, 2005 11:00 pm
Contact:
Post
by earlz » Sun Jul 01, 2007 6:36 pm
lol...yea, your right...was typing without thought really..