function overloading between int and string type : Function Overloaded « Function « C++






function overloading between int and string type

  
#include <iostream>
#include <string>

using namespace std;

int triple(int number);
string triple(string text);

int main(){
    cout << "Tripling 5: " << triple(5) << "\n\n";
    cout << "Tripling 'gamer': " << triple("gamer");

    return 0;
}

int triple(int number){
    return (number * 3);
}

string triple(string text){
    return (text + text + text);
}
  
    
  








Related examples in the same category

1.Functions differ in number of parametersFunctions differ in number of parameters
2.Overload abs() three waysOverload abs() three ways
3.Overload function: int and longOverload function: int and long
4.Create three functions called prompt( ) that perform this task for data of types int, double, and long
5.Overload function to accept integer or char * argumentOverload function to accept integer or char * argument
6.Overload the min() function.Overload the min() function.
7.Compute area of a rectangle using overloaded functions.Compute area of a rectangle using overloaded functions.
8.Overload function: int and floatOverload function: int and float