|
-
April 6th, 1999, 06:48 AM
#1
c++ question
The following code snippet works although my destructor of class B is declared private. Whereas, if I do not derive my class B virtual the following program fails to compile. Why? I am using VC++ 5.0.
class A {
public:
A() {
cout<<"\nIn constructor of A";
}
~A() {
cout<<"\nIn destructor of A";
}
};
class B : virtual public A {
public:
B() {
cout<<"\nIn Constructor of B";
}
private:
~B() {
cout<<"\nIn Destructor of B";
}
};
void main(void)
{
B b;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|