uninit_member:非静态类成员m_wszParams未在此构造函数中初始化,也不在它C++中调用的任何函数中初
uninit_member: Non-static class member m_wszParams is not initialized in this constructor nor in any functions that it calls in C++
我有IVerization类,这个类有两个成员变量(m_wszParams和m_wszParamType(。在此类构造函数中,我不初始化这些成员变量。稍后,在派生类(MyReader(中初始化这些变量。
因此,我收到警告"uninit_member:非静态类成员m_wszParams未在此构造函数中初始化,也未在其调用的任何函数中初始化。
要解决此警告,我可以在 IVerification 构造函数中使用 nullptr 初始化这些成员变量,如下所示吗?
IVerification::IVerification()
{
m_wszParams = nullptr;
m_wszParamType = nullptr;
}
以下是完整的代码:
.h 文件
class IVerification
{
public:
IVerification();
virtual ~IVerification();
protected:
wchar_t* m_wszParams;
wchar_t* m_wszParamType;
}
.cpp文件
IVerification::IVerification()
{
}
下面是派生类
我的阅读器.h 文件
class MyReader : public IVerification
{
public:
MyReader();
~MyReader();
public:
void SetParams(wchar_t* wszParams, wchar_t* wszParamType);
}
我的阅读器.cpp文件
void MyReader::SetParams(wchar_t* wszParams, wchar_t* wszParamType)
{
m_wszParamType = wszParamType;
m_wszParams = wszParams;
}
至少
第四类 { 公共: IVerization((= 默认值; 虚拟 ~IVerization((= 默认值; 保护: wchar_t* m_wszParams= 空点;wchar_t* m_wszParamType= 空点;};
下一步:指针不是你的朋友,使用std::string。
相关文章:
- 如何用参数值调用函数(仅在运行时已知)
- 从python中调用C++函数并获取返回值
- 当使用通配符和null指针调用函数时,对输出的说明
- 从R调用C++函数并对其进行集成时出错
- 使用QTreeView,如何通过调用函数只突出显示特定的行/列
- 如何在qt中从另一个类调用函数
- 在 COUT 语句中使用 COUT 调用函数
- 如何从线程中的不同模块调用函数?
- C++从函数指针数组调用函数
- 当 A 在 for 循环中调用函数 B 时,如何计算函数 A 的空间复杂度?
- 如何在 C/C++ 中从外部库调用函数
- 如何使用运算符在同一行中多次调用函数
- 是否可以创建一个从不同类调用函数的线程?
- 无法为类成员调用函数
- 如何从另一个标头 c++ 调用函数
- C++有什么方法可以在既不调用函数模板也不提供其模板参数的情况下引用函数模板?
- 如何只允许在调用函数 B 后调用函数 A?
- 我可以这样调用函数吗?
- 如何在 c++ 的类中递归调用函数方法?
- 为什么在指向对象的迭代器上调用函数不允许我更改对象本身?