-1
makedge
函数中的这种内存分配是什么类型?makeedge()返回的内存类型是静态还是动态类型?
#include<iostream>
#include<stdio.h>
using namespace std;
struct edge
{
int a;
int b;
edge(int a, int b)
{
this->a=a;
this->b=b;
}
};
edge makedge(int a, int b)
{
return edge(a, b);
}
int main(void)
{
edge e=makedge(5 , 6);
printf("%d %d\n", e.a, e.b);
}
当我尝试释放内存使用delete(&e)
。错误是
Error : double free or corruption (out): 0x00007fff6aee5d30 ***
在geeksforgeeks在线编译器。
?这听起来像你可以使用[良好的C++书](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – NathanOliver
只有'删除'你'新',和'删除[]'你'新的[]''。 –