Function Overloading in C++

#include <iostream>
using namespace std;
void myfunc(char charValue);
void myfunc(int intValue);
void myfunc(double doubleValue);

int main()
{
    myfunc('c');
    myfunc(12);
    myfunc(59.60);
    return 0;
}

void myfunc(char charValue)
{
    cout << "Char Value: " << charValue << endl;
}

void myfunc(int intValue)
{
    cout << "Int Value: " << intValue << endl;
}

void myfunc(double doubleValue)
{
    cout << "Double Value: " << doubleValue << endl;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *