成员变量char * point;
在构造函数中point = new int[10];point="hello";
在析构函数中delete[] point;
运行的时候出现错误 这是为什么 如果把point="hello";删了就不报错了
不好意思 是我打错了 是point = new char[10];
代码如下 :
#include<iostream>
using namespace std;
class C
{
char* point;
public :
C()
{
point = new char[5];
point = "fda";//这句话注销了就对了 不知道为什么
}
~C()
{
delete[] point;
}
};
main()
{
C c;
}
不知道为什么会报错