由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Initialization list的一个问题
相关主题
不明白C++的一个地方template 类的继承问题
vector在constructor里初始化问行C++代码
关于C/C++里的Static variable的memory allocation/initializac++类未完成初始化,如何引用this?
c++ initialize structC++ 中 myobject * a =new myobject[n] 的问题
问个copy constructor的问题question about const reference
一道Microsoft的面试题C++ question
vptr 到底是在第一个还是最后一个C++弱问
[合集] C++的弱问题C++ (direct vs indirect initialization)
相关话题的讨论汇总
话题: list话题: 书上话题: order话题: 变量
进入Programming版参与讨论
1 (共1页)
C*******l
发帖数: 105
1
我们都知道Initialization list里的变量要按顺序列,但如果中间想跳过一个变量,
那么这个变量是通过default ctor来初始化吧?然后后边的继续用Initialization
list来初始化。我想确认一下这样写会不会到别的编译器下造成问题。
s*****k
发帖数: 604
2
what language you are talking about?

【在 C*******l 的大作中提到】
: 我们都知道Initialization list里的变量要按顺序列,但如果中间想跳过一个变量,
: 那么这个变量是通过default ctor来初始化吧?然后后边的继续用Initialization
: list来初始化。我想确认一下这样写会不会到别的编译器下造成问题。

C*******l
发帖数: 105
3
c++

【在 s*****k 的大作中提到】
: what language you are talking about?
P********e
发帖数: 2610
4

~~~~~~~什么书上写的

【在 C*******l 的大作中提到】
: 我们都知道Initialization list里的变量要按顺序列,但如果中间想跳过一个变量,
: 那么这个变量是通过default ctor来初始化吧?然后后边的继续用Initialization
: list来初始化。我想确认一下这样写会不会到别的编译器下造成问题。

t****t
发帖数: 6806
5
任何一本不太差的C++的书上都会提到
至于读者会不会一目十行的把它跳过, 那就是另一回事了

【在 P********e 的大作中提到】
:
: ~~~~~~~什么书上写的

P********e
发帖数: 2610
6
hehe:)
The order of member construction is the order in which they are defined in
the class. Where they are in the construction list doesn't matters.
Why it should be in a order?

【在 t****t 的大作中提到】
: 任何一本不太差的C++的书上都会提到
: 至于读者会不会一目十行的把它跳过, 那就是另一回事了

a*****r
发帖数: 19
7
This is about morality instead of legality. Check out "effective C++".
Sometimes the order will bring up a
little problem.

【在 P********e 的大作中提到】
: hehe:)
: The order of member construction is the order in which they are defined in
: the class. Where they are in the construction list doesn't matters.
: Why it should be in a order?

1 (共1页)
进入Programming版参与讨论
相关主题
C++ (direct vs indirect initialization)问个copy constructor的问题
find bugs of c++ codes一道Microsoft的面试题
如何 initialize array member?vptr 到底是在第一个还是最后一个
问一个 copy constructor 的问题 (C++)[合集] C++的弱问题
不明白C++的一个地方template 类的继承问题
vector在constructor里初始化问行C++代码
关于C/C++里的Static variable的memory allocation/initializac++类未完成初始化,如何引用this?
c++ initialize structC++ 中 myobject * a =new myobject[n] 的问题
相关话题的讨论汇总
话题: list话题: 书上话题: order话题: 变量