advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

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. 


advertisement
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?



advertisement