首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

疯了!error: 'clsComn' was not declared in this scope解决方案

2012-08-14 
疯了!error: clsComn was not declared in this scopeCommon.h文件如下:namespace Comm{class Common{pu

疯了!error: 'clsComn' was not declared in this scope
Common.h文件如下:
namespace Comm
{

class Common
{
public:
void initLogField();

private:
friend class TestLog;
};

} /* namespace Comm */


Common.cpp文件如下:

#include "Common.h"

using namespace std;

namespace Comm
{

void Common::initLogField()
{
  。。。
}
}


TestLog.h文件如下:

#include "Common.h"

#ifndef TESTLOG_H_
#define TESTLOG_H_

using namespace Comm;

class TestLog
{
public:
Common clsComn; //已经声明实例了啊

private:
short calDev(short p_num);
};
#endif /* TESTLOG_H_ */


TestLog.cpp文件如下:

#include "TestLog.h"

using namespace Comm;


short calDev(short p_num)
{
  clsComn.initLogField(); //编译错误error: 'clsComn' was not declared in this scope

  return rtn;
}

其他都是这么写的,怎么就这个过不去了呢?大侠帮忙!!!!

[解决办法]
很正常啊。

C/C++ code
short calDev(short p_num)  // 改成short TestLog::calDev(short p_num)就OK了{  clsComn.initLogField(); //编译错误error: 'clsComn' was not declared in this scope  return rtn;} 

热点排行