class Base{
char* s1;
public: ...
~Base(){
delete s1}
}
class Derived:public Base{
char* s2;
public: ...
//the constructor of the derived class will call the constructor of the
//base class, so derived will contain s2 and s1 too.
~Derived(){
//HERE
}
void main(){
...
Base x[5];
...
};
Questions:
1. what should i write in the destructor of the derived class?
does the derived class inherites the destructor from the
base class, so that in the destructor of the derived class the
destructor of the base class will be called automatically, and
i only have to delete s2? or it doesnt and i have to delete there
both elements (and if so, does the order matters)?
2. is the statement "Base x[5];" correct? can i store in a vector
elements of type class? or i can only reffer to the class by a
pointer?