Visual C++ .NET/Class/Overload

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Overload Methods

<source lang="csharp">

  1. include "stdafx.h"
  2. include <typeinfo.h>
  3. 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));

}

 </source>