struct 里有指针 记得要重写构造函数和析构函数

it2022-05-09  25

struct ImageInfo{ BITMAPINFO header; void* image;

 ImageInfo() {  image = NULL; }

 ~ImageInfo() {  if(image!=NULL)  {   delete image;   image = NULL;  } }};

结果是当进入函数体就会实例化,而不是执行到它! 所以路途退出时,出会析构错误!呵呵

转载于:https://www.cnblogs.com/nanshouyong326/archive/2009/08/24/1552982.html


最新回复(0)