ccplusplus.com
Learn C, C++ Concepts
Friday, February 10, 2012
using initializer list c++
/************************************************************************* * File : initializer-list.cpp * Author : Saurabh Gupta * Desc : using initializer list c++ * Source : http://www.ccplusplus.com/p/c_15.html * Created : 7:15 PM Friday, February 10, 2012 *************************************************************************/ #include
#include
using namespace std; /* * create a structure and add some elements */ struct ccplusplus { string strSiteName; string strOwner; int nAge; string strLocation; string strDateCreated; }; int main () { /* * initializer list */ ccplusplus info = {"http://www.ccplusplus.com/", "Saurabh Gupta", 24, "India", "19-Dec-2011"}; cout << info.strSiteName << endl; cout << "Owner = " << info.strOwner << endl; cout << "Age = " << info.nAge << endl; cout << "Location = " << info.strLocation << endl; cout << "Created = " << info.strDateCreated << endl; return 0; } /* * OUTPUT * [sgupta@rhel6x86 cpp]$ c++ initializer-list.cpp -o initializer-list [sgupta@rhel6x86 cpp]$ ./initializer-list http://www.ccplusplus.com/ Owner = Saurabh Gupta Age = 24 Location = India Created = 19-Dec-2011 [sgupta@rhel6x86 cpp]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment