由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Global(static) variable initialization question
相关主题
[合集] which design pattern is used if a static variable insidRe: can destructor be static?
c++ singleton questionsstatic variable存在heap还是stack?
判断Python程序员水平的一个试题static 变量放在哪里?C++
[合集] singleton and staticWhat're the three types of memory allocated for C++ variables?
请问static variable init的问题?another c++ interview question
how to implement singleton without static variable?[c++] static function in a class
一个C的问题:从一个instance到多个instance的改动static initialization dependency c++
问一个java基础的初始化的问题,一直搞不明白c++ 不自动initialize变量么?
相关话题的讨论汇总
话题: singleton话题: static话题: global话题: include
进入Programming版参与讨论
1 (共1页)
c********e
发帖数: 383
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
p***o
发帖数: 1252
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

c********e
发帖数: 383
3
u think i would bother to copy my code here if i know the answer?

【在 p***o 的大作中提到】
: 为什么sbin是0不是1?
c********e
发帖数: 383
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?
1 (共1页)
进入Programming版参与讨论
相关主题
c++ 不自动initialize变量么?请问static variable init的问题?
error LNK2001:的错误如何改正?how to implement singleton without static variable?
请问关于c++实现singleton的问题?一个C的问题:从一个instance到多个instance的改动
A question about singleton问一个java基础的初始化的问题,一直搞不明白
[合集] which design pattern is used if a static variable insidRe: can destructor be static?
c++ singleton questionsstatic variable存在heap还是stack?
判断Python程序员水平的一个试题static 变量放在哪里?C++
[合集] singleton and staticWhat're the three types of memory allocated for C++ variables?
相关话题的讨论汇总
话题: singleton话题: static话题: global话题: include