ccplusplus.com
Learn C, C++ Concepts
Friday, February 24, 2012
reference to an array c++
/************************************************************************* * File : reference-to-array.cpp * Author : Saurabh Gupta * Desc : reference to an array c++ * Source : http://www.ccplusplus.com/p/c_15.html * Created : 9:51 AM Friday, February 24, 2012 * Note : *************************************************************************/ #include
using namespace std; void print(int (&arr)[3]) { for(int i=0; i<3; ++i) { cout << arr[i] << endl; } } int main() { int array[3]={1,2,3}; print(array); return(0); } /* * OUTPUT * [sgupta@rhel6x86 cpp]$ c++ reference-to-array.cpp -o reference-to-array [sgupta@rhel6x86 cpp]$ ./reference-to-array 1 2 3 [sgupta@rhel6x86 cpp]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment