You need to use pointers to achieve that, something like this: you are truncating your values if you don't.
So: Base obj = Derived objD; //isn't valid it performs a cast and you will have a Base object
You need Base* obj = Derived *objD; // and this is ok, virtual mechanism works with this
Bookmarks