Writing Two Versions of a Function with overloading function - C++ Function

C++ examples for Function:Function Overload

Description

Writing Two Versions of a Function with overloading function

Demo Code

#include <iostream>
#include <string> 
using namespace std;

void printName(string first, string second){
  cout << first << " " << second << endl;
}

void printName(int first, int second){
  int sum = first + second;
  cout << first << " " << second << " " << sum << endl;
}

int main(){/* w  ww.j  av a  2s  . c om*/
  printName("A","B");
  printName(15,20);
  return 0;
}

Result


Related Tutorials