#include <iostream>
using namespace std;
class boiler
{
private:
static boiler uniqueInstance;
bool boilerEmpty;
bool mixtureBoiled;
boiler()
{
boilerEmpty = true;
mixtureBoiled = false;
}
public:
static boiler getInstance()
{
if(uniqueInstance == NULL)
{
uniqueInstance = new boiler();
}
return uniqueInstance;
}
};
以上法典重述标题中的错误。
anisha@linux-y3pi:~> g++ -Wall test.cpp
test.cpp: In static member function ‘static boiler boiler::getInstance()’:
test.cpp:22:26: error: no match for ‘operator==’ in ‘boiler::uniqueInstance == 0l’
test.cpp:24:34: error: no match for ‘operator=’ in ‘boiler::uniqueInstance = (operator new(2u), (<statement>, ((boiler*)<anonymous>)))’
test.cpp:5:1: note: candidate is: boiler& boiler::operator=(const boiler&)
为什么? 我们能否将“目标”与民族解放军进行比较? 是否存在一些同yn问题?