Overloaded function print

Posted by Olga Shirokova on Stack Overflow See other posts from Stack Overflow or by Olga Shirokova
Published on 2012-12-01T17:01:49Z Indexed on 2012/12/01 17:03 UTC
Read the original article Hit count: 196

Filed under:
|

For one of the assignments I need to create an overloaded function print that prints an element or all elements of an array. I have no problem with printing the entire array:

for( int i = 0; i < size; i++)
    cout << list [ i ] <<endl;

But how do I make the same function to print only one particular element? The way I see it is to ask a user what to print, either one element or all numbers. Or am I missing something here?

© Stack Overflow or respective owner

Related posts about arrays

Related posts about printing