我收到了这个警告,它在整个构建过程中重复出现 警告来自以下代码逻辑:行号6
class sample
{
private: //1
// Private so that it can not be called //2
sample(); //3
sample(sample const&); //4
// Assigning copy constructor with default constructor //5
sample& operator= (sample const&){}; //6
// //7
static sample *m_Instancesample; //8
static bool m_binstanceFlagsample; //9
public: //10
static sample *getInstance(); //11
~sample(); //12
void dummy();
};
答案 0 :(得分:3)
您的sample& operator= (sample const&){};
已定义了返回类型,但您没有返回任何内容。实现该功能或删除{}
答案 1 :(得分:1)
sample& operator= (sample const&){};
^^
{}
部分用空体定义函数 - 定义缺少return语句。
定义函数正确或删除{}
(即声明函数并在别处定义)。
答案 2 :(得分:0)
替换如下:
sample& operator= (sample const&){};
使用:
const sample& operator= (sample const& sampleInstance)
{
//Get the instance of your sample class as it is singleton you will get the same instance
return *sample::getInstance();
};