sedj
Programmer
- Aug 6, 2002
- 5,610
Hello,
Can someone explain why the destructor does not seem to be called ?
The output is :
But the "destruct" is not present. I'm clearly missing a fundamental point in abstract C++ classes - can someone tell me what ?
Thanks
Can someone explain why the destructor does not seem to be called ?
The output is :
construct
Hello
But the "destruct" is not present. I'm clearly missing a fundamental point in abstract C++ classes - can someone tell me what ?
Thanks
Code:
#include <stdio.h>
// the abstract class
class AbstractClass {
public:
virtual void sayHello() = 0;
};
// an implementation
class ClassImpl : public AbstractClass {
public:
ClassImpl() {
printf("construct\n");
}
~ClassImpl() {
printf("destruct\n");
}
void sayHello() {
printf("Hello\n");
}
};
// run the test
int main() {
AbstractClass* qqq = new ClassImpl();
qqq->sayHello();
delete(qqq);
}