10 Mart 2010 Çarşamba

C++ da Yapıcı ve Yokedici Tanımlama

//www.ethemsulan.com
#include <cstdlib>
#include <iostream>
using namespace std;
class myclas{
      int who;
      public:
             myclas(int n){
                        who=n;
 cout<<who<<" constroctor is call\n";
                       }
~myclas(){cout<<"destcontractor is call: "<<who<<endl;}
             int id(){return who;}
      };
class myclas1{
      int who;
      public:
             myclas1(int n){
                        who=n;
cout<<who<<" constroctor is call\n";
                        }
~myclas1(){cout<<"destcontractor is call: "<<who<<endl;}
             int id(){return who;}
      };
void fonk(myclas o){cout<<o.id()<<" alindi"<<endl;}
void fonk(myclas1 &o){cout<<o.id()<<" alindi"<<endl;}
int main(int argc, char *argv[])
{
    myclas x(12);
    fonk(x);
    cout<<endl;
    myclas1 y(200);
    fonk(y);
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder