Delete An Object In Inheritance dynamically

I'm facing a difficulty with this little question in my quiz question.
Here's the question:
- Write Two (2) C++ statement to allocate and delete an object of class Parent dynamically.

*Sorry for my poor programming skill

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 #include <iostream>
using namespace std;

class Parents{
 public:
    Parents(){cout<<"I'm a Father\n";}
    virtual ~Parents(){cout<<"I'm a Mother\n";}
};

class Son : public Parents{
  public:
  Son(){cout<<"I'm a Son\n";}
  virtual ~Son(){cout<<"I'm a Daughter\n";}

};

int main()
{
//missing code here
    return 0;
}
Last edited on
Dynamically allocate means they want you to use new.
means that i need to use something like this?
1
2
*ptr = Parents;
ptr = new Parents;
Topic archived. No new replies allowed.