Sequence Constructors Add C++09 Initialization Syntax to Your Homemade Classes
You can initialize C++09 Standard Library containers with a list of initializers, but what about your homemade container classes? Sequence constructors enable you to initialize instances of your homemade classes in a similar fashion.
by Danny Kalev
March 12, 2009
previous 10-Minute Solution demonstrated the new initialization rules of C++09, which enable you to initialize standard containers (among the rest) in the following manner:
vector <int> scores = {89, 76, 98, 93}; //C++09
A new constructor type called a sequence constructor makes this syntax possible. The following sections will show how to enable the ={val1,val2,...} initialization syntax by adding a sequence constructor to your homemade classes.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!