Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
#include <iostream.h>
#include <conio.h>
void main()
{
void sum(int []={5,8});
sum();

getch();

}
void sum(int x[])
{
for(int i=0;i<=2;i++)
cout<<x[i];
}



I use array as default arguments but my program have lot of errors
Posted
Comments
Maximilien 19-Feb-13 8:34am    
Default arguments are evil, more so for "complex" data like vectors/arrays.

DON'T USE THEM.

1 solution

#include <iostream>
#include <conio.h>

using namespace std;

void sum(int x[])
{
    for(int i=0;i<2;i++)
        cout<<x[i];
}

void main()
{
    int values[] = {5,8};
    sum(values);
    getch();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900