我正在用 C++ 编写内存分配程序,但在程序中出错。
我不明白发生了什么。
请帮忙。
#include<iostream>
using namespace std;
class Test{
int *m_ptr;
private:
void Test(){
m_ptr = new int(4);
}
~Test(class Test){
cout<<"Object gets destroyed..";
}
};
int main(){
Test *ptr = new Test();
delete [] ptr;
}
Run Code Online (Sandbox Code Playgroud)
我也是 C++ 的新手
c++ ×1