【发布时间】:2013-05-16 21:47:08
【问题描述】:
我正在处理一段代码,但我不能 100% 确定它的正确性。请问您能告诉我您对此有何看法吗? (我在 Qt 中编码)
只是一个示例:
CustomWidget *widget; //defined as private
widget = new CustomWidget(this);
connect(widget,SIGNAL(onCLose(), this, SLOT(onWidgetClose()));
widget = new CustomWidget(this);
connect(widget,SIGNAL(onCLose(), this, SLOT(onWidgetClose()));
widget = new CustomWidget(this);
connect(widget,SIGNAL(onCLose(), this, SLOT(onWidgetClose()));
void onWidgetClose(){
CustomWidget *w = findClosedWidget();
delete w;
}
【问题讨论】:
-
有一个更适合代码审查的地方 - 另一个名为 Code Review 的 SO 站点:codereview.stackexchange.com
标签: c++ qt pointers memory allocation