RE: vtable on stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Frank,

> Do virtual functions work with class objects created on the stack?

Yes.

> Consider the example below.

I think you may be misunderstanding this line:
   A y = B();

That makes an A on the stack, since y is an A.  y does not become a B from the assignment.  Rather B is sliced to an A.

So that A y = B(); is not analogous to:
   A* x = new B();

To fix your example, do this:
   B y = B();

Sincerely,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux