English 中文(简体)
A. 入门
原标题:class instance member initialisation
  • 时间:2011-11-08 10:20:53
  •  标签:
  • c++

如果某个班级有自己是班级的试办成员,施工者ALWAYS是否必须在施工者初步名单中为之提供初步证明?

在某些情况下,在我的法典中,这导致了非常长的初始者名单,这是做事的路。 我只问,因为它看着迷人,但如果它想到怎样做,那么那就错了。

is the same also the case for constant instance member variables?

最佳回答

For objects, you will have to initialize all members that do not have a default constructor. If you omit a member in the initialization list, its default constructor will be used (or its value will be undefined for primitive types).

<>原始>类型 (int,pointers),其法律效力不是予以初步确定,但其价值为un specified

最后,must initialize reference to otherbject (std:string &)。

See this accreditation/a> for more.

此外,我要指出,如果你的班子有很多成员,也许可以表明你应该将其分成几个较小的班级。 最佳做法是开设只有一项责任的班级(见http://en.wikipedia.org/wiki/Single_responsibility_principle”rel=“nofollow noreferer”>。

问题回答

如果你有违约构造者(没有参数),那么你就不需要明确予以启动。

经常发生的情况是,在出现违约情况时,没有点什么? 因此,除非你有选择,否则根本就没有意义。 (当然,如果出于任何原因,你可以做些什么的话)。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签