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

c++中,vector的使用有关问题,求指点

2013-06-26 
c++中,vector的使用问题,求指点写了一个类,成员包含一个静态的vector对象。如下:class test{public:static

c++中,vector的使用问题,求指点
写了一个类,成员包含一个静态的vector对象。
如下:
class test{
public:
      static vector< int > m_int_vec;
};
然后在main函数调用。
如下:
test::m_int_vec.push_back(1);
结果提示“无法解析外部符号”。 C++
[解决办法]
静态成员变量的定义必须写在类定义外面,写在类定义内部的只能叫声明

.h:

class test{
public:
      static vector< int > m_int_vec;
};

.cpp:

vector< int > test::m_int_vec;

热点排行