12 Mart 2010 Cuma

C++ Constructor Overloading Example

//www.ethemsulan.com
#include <cstdlib>
#include <iostream>
using namespace std;
class myclas{
      int x;
      public:
             myclas(){x=0;}
             myclas(int n){x=n;}
             int getx(){return x;}
      };
int main(int argc, char *argv[])
{
    myclas ob1(10);
    myclas ob2;
    cout<<ob1.getx()<<' '<<ob2.getx()<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder