由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请教类里面的静态变量如何使用,具体例子请进来看
相关主题
关于linker, loader, complier问一道关于reverse a C-string的问题
google首页的吃豆子游戏是怎么实现的?请教一个新鲜算法面试题
C++一问郁闷啊 刚刚apple电面
网上c sample question的一堆错误报几个面经攥人品吧
str2int中overflow该如何处理?Google Offer
如何准备compiler的知识?我决定转CS啦。。。下定决心啦!!!!不回头看啦!!!!
询问Bloomberg online skill assessment递归, dp 平时工作中用的不多, 为什么面试的时候考这么多
Tricky Pointer Problems -- Which level are you?How can I upload e-book
相关话题的讨论汇总
话题: book话题: detail2话题: detail1话题: string话题: id1
进入JobHunting版参与讨论
1 (共1页)
c**z
发帖数: 669
1
complier能过,但是run不过,请指教
class book
{
public:
book(long id1,string detail1 )
{ id=id1; detail=detail1;
}
book()
{
}
void addbook(long id2, string detail2)
{ book b(id2,detail2);
books.push_back(b);
}
private:
long id;
string detail;
static vector books;
};
void main()
{
book b1;
b1.addbook(1,"a");
b1.addbook(2,"b");
}
q****x
发帖数: 7404
2
add this line after the class definition:
vector book::books;
the line of static ... in your code is a declaration, not definition. the
variable must be defined before used.

【在 c**z 的大作中提到】
: complier能过,但是run不过,请指教
: class book
: {
: public:
: book(long id1,string detail1 )
: { id=id1; detail=detail1;
: }
: book()
: {
: }

l***i
发帖数: 1309
3
In addition, don't you need to declare the function with static?
a********m
发帖数: 15480
4
这能通过编译?应该是link err吧。有
f*******t
发帖数: 7549
5
static变量也要初始化
1 (共1页)
进入JobHunting版参与讨论
相关主题
How can I upload e-bookstr2int中overflow该如何处理?
问个sql 题如何准备compiler的知识?
question about travel询问Bloomberg online skill assessment
网申系统的问题Tricky Pointer Problems -- Which level are you?
关于linker, loader, complier问一道关于reverse a C-string的问题
google首页的吃豆子游戏是怎么实现的?请教一个新鲜算法面试题
C++一问郁闷啊 刚刚apple电面
网上c sample question的一堆错误报几个面经攥人品吧
相关话题的讨论汇总
话题: book话题: detail2话题: detail1话题: string话题: id1