游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1963|回复: 1

c++中静态的vector会出错?!

[复制链接]

13

主题

978

帖子

978

积分

高级会员

Rank: 4

积分
978
发表于 2005-2-5 16:28:00 | 显示全部楼层 |阅读模式
我定义了一个类

class atest{
private:
    static vector<int> _ivec;
public:
    …………省略
}
我发现只要是在vector<int>前面加上static就会出错。
test error LNK2001: 无法解析的外部符号 "private: static class std::vector<int,class std::allocator<int> > atest::ivec" (?ivec@atest@@0V?$vector@HV?$allocator@H@std@@@std@@A)

如果不加就没有问题。
为什么呢?是vs.net2002对vector支持不好吗?

8

主题

111

帖子

163

积分

注册会员

Rank: 2

积分
163
发表于 2005-2-5 16:38:00 | 显示全部楼层

Re:c++中静态的vector会出错?!

static的变量还要在外面申明一下的
在你的cpp文件里加一句:
vector<int> atest::_ivec;
可能就好了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-24 06:48

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表