Wednesday 4 February 2015

C++ programming code for function overloading

C++ programming code for function overloading

#include <iostream>
 
using namespace std;
 
/* Number of arguments are different */
 
void display(char []);  // print the string passed as argument
void display(char [], char []);
 
int main()
{
   char first[] = "C programming";
   char second[] = "C++ programming";
 
   display(first);
   display(first, second);
 
   return 0;
}
 
void display(char s[])
{
   cout << s << endl;
}
 
void display(char s[], char t[])
{
   cout << s << endl << t << endl;
}

No comments:

Post a Comment