疯了!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;
}
其他都是这么写的,怎么就这个过不去了呢?大侠帮忙!!!!
[解决办法]
很正常啊。
short calDev(short p_num) // 改成short TestLog::calDev(short p_num)就OK了{ clsComn.initLogField(); //编译错误error: 'clsComn' was not declared in this scope return rtn;}