C++ 14 Quick Syntax Reference by Mikael Olsson

C++ 14 Quick Syntax Reference by Mikael Olsson

Author:Mikael Olsson
Language: eng
Format: epub, pdf
ISBN: 9781484217269
Publisher: Apress


Aggregate Initialization

There is a syntactical shortcut available when initializing an object called aggregate initialization. This syntax allows fields to be set by using a brace-enclosed list of initializers, in the same way as can be done with arrays. Aggregate initialization can only be used when the class type does not include any constructors, virtual functions or base classes. The fields must also be public, unless they are declared as static. Each field will be set in the order they appear in the class.

// Aggregate initialization

MyClassa = { 2 }; // iis 2



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.