C++ Function Overloading Two Versions of a Function

Description

C++ Function Overloading Two Versions of a Function

#include <iostream>

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(){/*from  w  ww  .  ja v a2  s.  c o  m*/
  printName("A","B");
  printName(15,20);
  return 0;
}



PreviousNext

Related