如标题所述,这是我的代码:
class Foo {
public:
Foo (int charSize) {
str = new char[charSize];
}
~Foo () {
delete[] str;
}
private:
char * str;
};
对于这个类,有什么区别:
int main () {
Foo* foo = new Foo(10);
delete foo;
return 0;
}
和
int main () {
Foo* foo = new Foo(10);
foo->~Foo();
return 0;
}