What is wrong in the following code:
class Parent { 
  public:
    ~Parent() { }
    virtual void method() { }
};

class Child : public Parent { 
  public:
    Child() { /* creating resources */ }
    ~Child() { /* cleaning resources */ }
    void method() { /* code */ }
};

int main() {
  Parent * obj = new Child;
  // code
  delete obj;
  return 0;
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes