我已经用 cppcheck 检查了我的代码,它说我的char outStr[256]
字段应该在构造函数的初始化列表中初始化。
warning: Member variable 'outStr' is not initialized in the constructor.
该字段仅在此方法中使用:
const char* toStr(){
sprintf(outStr,"%s %s", id.c_str(), localId.c_str());
return outStr;
}
c("")
添加到初始化列表中会更好吗?还是cppcheck错了?还是有其他方法可以绕过它?