0
Object creation
class A{}; class B : public A{}; int main() { //Why can we write this: A* obj = new B; //and can't do this: B*obj = new A; //error return 0; }
1 Resposta
+ 2
Class A is like a model for class B. B has just new features.
For example, you have a mother class Vehicle (A) and a derived class Motorbike (B) : all Motorbike are Vehicle but all Vehicle aren't Motorbike.