Hi Bob,
Currently you cannot use member initialization list for a nonstatic array of a class if it does not have a default constructor. When you try to initialize the array, you will encounter the compiler
error C2536. You may refer to:
Compiler Error C2536
http://msdn.microsoft.com/en-us/library/9f53ks1w.aspx
If the class has a default constructor, you can explicitly initialize it like the following code:
class CInner {
public:
// Constructor
CInner(int x) : Value(x) {}
CInner(){}
// Member variable
int Value;
};
class COuter {
public:
CInner InnerValue;
CInner m_Inners[2];
// Constructor
COuter() :
InnerValue(2),m_Inners()
{}
};
The code can be compiled, however you may encounter the warning C4351 and I do not think that it is useful to use such initialization for an array.
You can refer to this article for further inforamtion:
Compiler Warning (level 1) C4351
http://msdn.microsoft.com/en-us/library/1ywe7hcy.aspx
Best regards,
Charles Wang
Microsoft Online Community Support
================================================== =========
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at:
ms****@microsoft.com.
================================================== =========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...#notifications.
Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================== ==========
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== =======