[Assorted-commits] SF.net SVN: assorted:[1299] sandbox/trunk/src/cc/init.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-03-17 17:18:53
|
Revision: 1299 http://assorted.svn.sourceforge.net/assorted/?rev=1299&view=rev Author: yangzhang Date: 2009-03-17 17:18:39 +0000 (Tue, 17 Mar 2009) Log Message: ----------- demo of struct initialization Added Paths: ----------- sandbox/trunk/src/cc/init.cc Added: sandbox/trunk/src/cc/init.cc =================================================================== --- sandbox/trunk/src/cc/init.cc (rev 0) +++ sandbox/trunk/src/cc/init.cc 2009-03-17 17:18:39 UTC (rev 1299) @@ -0,0 +1,23 @@ +// Demo of struct initialization. +#include <iostream> +using namespace std; +struct s { int a, b, c, d, e, f, g, h[10]; }; +void show(s &x) { + cout << x.a << ' ' + << x.b << ' ' + << x.c << ' ' + << x.d << ' ' + << x.e << ' ' + << x.f << ' ' + << x.g << ' '; + for (int i = 0; i < 10; ++i) + cout << x.h[i] << ' '; + cout << endl; +} +int main() { + // Garbage initialization. + { s x; show(x); } + // Initializes everything to be zero. + { s x = {0}; show(x); } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |