I have no clue what the answer is.
Which of the following dynamically allocates an object of type ourClass?
a) ourClass ourPtr;
ourPtr = new ourClass;
b) ourClass ourClassObj = new ourClass;
c) typedef ourClass* ourClassPtrType;
ourClassPtrType ourClassPtr;
ourClassPtr = new ourClassPtrType;
d) typedef ourClass* ourClassPtrType;
ourClassPtrType ourClassPtr;
ourClassPtr = new ourClassPtrType;
The class Derived is publicly derived from a class Base. The Base class has a public member function mem() that is not virtural. The member function mem() is redefined in class Derived.
Base *dPtr = new Derived;
dptr ->mem();
In the second line, which version of mem() is accessed?
I think the aswer is "b" but i'm not sure.
a) Base::mem()
b) Derived::mem()
c) This code causes an error
d) Both Base::mem() and Derived::mem()
any help will be appreciated.