Redian新闻
>
Global(static) variable initialization question
avatar
Global(static) variable initialization question# Programming - 葵花宝典
c*e
1
I wrote a small piece of code, if you run sbin, the out put is 0 however if
you run shbin the out put is one , which is what i expect...
can not figure out why. Thanks,
///////////////////////////////////////////
//lib.h
#include
#include
#include
template
class SingleTon
{
public:
static T * instance ();
protected:
SingleTon () {}
static T * instance_;
};
class A : public SingleTon
{
public:
A () {}
int size () { return box_.size (); }
void
avatar
p*o
2
为什么sbin是0不是1?

【在 c********e 的大作中提到】
: I wrote a small piece of code, if you run sbin, the out put is 0 however if
: you run shbin the out put is one , which is what i expect...
: can not figure out why. Thanks,
: ///////////////////////////////////////////
: //lib.h
: #include
: #include
: #include
: template
: class SingleTon

avatar
c*e
3
u think i would bother to copy my code here if i know the answer?

【在 p***o 的大作中提到】
: 为什么sbin是0不是1?
avatar
c*e
4
turns out that the test.o is not linked in at all since
there is no symbol needed from it by main.cpp anywhere..

【在 c********e 的大作中提到】
: u think i would bother to copy my code here if i know the answer?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。