请看下面的代码
UIHandler.cpp
#include "UIHandler.h"
#include <iostream>
using namespace std;
UIHandler::UIHandler()
{
}
UIHandler::~UIHandler(void)
{
}
UIHandler *UIHandler::getInstance()
{
if(uiHandler==NULL)
{
uiHandler = new UIHandler();
}
return uiHandler;
}
UIHandler.h
#pragma once
class UIHandler
{
public:
~UIHandler(void);
static UIHandler *getInstance();
private:
UIHandler *uiHandler();
UIHandler();
};
我是 C++ 新手,我正在尝试在这里实现单例模式。但是,这个是错误的!它说“ expression must be a modifiable lvalue
”,在那个地方uiHandler = new UIHandler();
为什么是这样?请帮忙!