Overload Methods : Overload « Class « Visual C++ .NET






Overload Methods

 
#include "stdafx.h"
#include <typeinfo.h>
#using <mscorlib.dll>
using namespace System;

class MyMath {
public:
    double Add(double x, double y);
    int Add(int x, int y);
};
double MyMath::Add(double x, double y) {
    return x + y;
}
int MyMath::Add(int i, int j) {
    return i + j;
}
void main(void)
{
    MyMath inst;
    Console::WriteLine(inst.Add(10,20));
    Console::WriteLine(inst.Add(1.5,2.7));
}

   
  








Related examples in the same category