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

请教在类中可以 定义静态的vector容器吗

2012-02-24 
请问在类中可以 定义静态的vector容器吗?在类example.h中声明了staticstd::vector intvec(5)在example.

请问在类中可以 定义静态的vector容器吗?
在类example.h中声明了static   std::vector <int>   vec(5);  
在example.cpp中定义了   std::vector <int>   Example::vec(5,0),结果编译的时候出错,请问该怎样定义?

[解决办法]
声明中不要带初始化参数。改为:
static std::vector <int> vec;

热点排行
Bad Request.