S
shuisheng
Dear All,
If I define a virtual function to be inline, is it really inline? Or it
is inline in some cases, and not in other cases. Would you please help
me to look at the following case.
struct A
{
int i;
A() {i = 0;}
virtual void Add() {i++;}
};
struct B : public A
{
virtual void Add() {i += 2;}
};
int main()
{
A a;
a.Add(); // inline ?
B b;
b.Add(); // inline ?
A *pa = new A();
pa->Add(); // not inline?
A *pb = new B();
pb->Add(); // not inline?
return 0;
}
Thanks!
Shuisheng
If I define a virtual function to be inline, is it really inline? Or it
is inline in some cases, and not in other cases. Would you please help
me to look at the following case.
struct A
{
int i;
A() {i = 0;}
virtual void Add() {i++;}
};
struct B : public A
{
virtual void Add() {i += 2;}
};
int main()
{
A a;
a.Add(); // inline ?
B b;
b.Add(); // inline ?
A *pa = new A();
pa->Add(); // not inline?
A *pb = new B();
pb->Add(); // not inline?
return 0;
}
Thanks!
Shuisheng