//t.h
class Ctest
{
public:
Ctest();
static int GetM();
static int m_int ;
};
//t.cpp
#include "t.h"
int Ctest::GetM()
{
return m_int;
}
Ctest()::Ctest():m_int(1){};// test.cpp : 定义控制台应用程序的入口点。
//#include "stdafx.h"
#include "t.h"
#include "iostream.h"
int _tmain(int argc, _TCHAR* argv[])
{
cout<<Ctest::GetM()<<endl;
return 0;
}
//编译的提示
test error LNK2019: 无法解析的外部符号 "public: static int __cdecl Ctest::GetM(void)" (?GetM@Ctest@@SAHXZ) ,该符号在函数 _main 中被引用
class Ctest
{
public:
Ctest();
static int GetM();
static int m_int ;
};
//t.cpp
#include "t.h"
int Ctest::GetM()
{
return m_int;
}
Ctest()::Ctest():m_int(1){};// test.cpp : 定义控制台应用程序的入口点。
//#include "stdafx.h"
#include "t.h"
#include "iostream.h"
int _tmain(int argc, _TCHAR* argv[])
{
cout<<Ctest::GetM()<<endl;
return 0;
}
//编译的提示
test error LNK2019: 无法解析的外部符号 "public: static int __cdecl Ctest::GetM(void)" (?GetM@Ctest@@SAHXZ) ,该符号在函数 _main 中被引用
解决方案 »
- error C2059: syntax error : 'bad suffix on number'各位大神帮忙解决下
- VC2005关于X64编译
- 树控件问题
- 初级问题:请问怎么知道一个工程中到底添加了哪些组件和控件
- 关于调试的问题!Build(F7)时没任何问题,可Execute(Ctrl+F5)时就不行了
- 请问SetScrollSizes应该在那里调用啊?
- 怎么用汇编语言读取指定端口数据(Windows 2000 profession),急死了!
- 我想让MDI窗体生成的子窗体没有最大化,最小化,关闭
- 求助,大家帮忙看看!!
- 关于SDK的问题
- 请教:我在一个类中定义变量,出现内存地址问题
- 控件嵌入到IE中,接收不到箭头键,怎么办
#include "t.h"int Ctest::m_int = 1;int Ctest::GetM()
{
return m_int;
}
Ctest()::Ctest
{
}
只能对普通成员初始化,
不能对静态变量初始化。
可以单独对静态变量初始化.将
Ctest()::Ctest():m_int(1){};
改成
static Ctest()::m_int=1;
Ctest()::Ctest(){};