• 3968阅读
  • 1回复

ISO C++ forbids declaration of `Globals' with no type 错误怎么办? [复制链接]

上一主题 下一主题
离线leehus
 

只看楼主 倒序阅读 楼主  发表于: 2009-07-23
globals.h源码:
#ifndef GLOBALS_H
#define GLOBALS_H
#include <QtCore>

class Globals
{
public:
 ~Globals(){}
    static Globals& instance();
 static QMap<QString, QString> _users;
private:
    Globals(){}
    static Globals *_instance;
};
Globals* Globals::_instance = NULL;
Globals& Globals::instance()
{
      if (_instance == NULL)
      {
            _instance = new Globals();
      }
      return *_instance;
}
#endif

然后在login.h文件中#include "globals.h"

定义Globals *globals=Globals::instance();出错 ISO C++ forbids declaration of `Globals' with no type
怎么回事?
[ 此帖被leehus在2009-07-23 12:28重新编辑 ]
离线leehus

只看该作者 1楼 发表于: 2009-07-24
没人帮我看看吗
自己顶一下
快速回复
限100 字节
 
上一个 下一个