I am trying to understand the following code kindly help me
#include<iostre am>
using namespace std;
class base {
private:
~base() {cout << "This is base destructor"<<en dl ;}
friend class drived;
public:
base() {cout<<"I am base constructor"<<e ndl;}
virtual void test1() {cout << "i am base virtual method " <<endl;}
};
class drived : virtual public base { // Line 11
remove the virtual keyword
public:
drived () {cout << "I am derived contructor"<<en dl;}
~drived() {cout << "This is drived destructor"<<en dl ;}
};
class drived1 : public drived {
};
int main () {
// drived* b1 ;
base* b1 ;
b1 =new drived1;
// delete b1;
return 1;
}
g++ privdest.cpp
privdest.cpp: In constructor `drived1::drive d1()':
privdest.cpp:5: `base::~base()' is private
privdest.cpp:23 : within this context
does not compile as i expected
but when i removed the virtual from line number 11 i was able to
compile it why so ??