9 Mart 2010 Salı

C++ Pointer Kullanımı

//www.ethemsulan.com
#include <cstdlib>
#include <iostream>
using namespace std;
class myclas{
      int a;
      public:
             myclas(int x);      
             int get();
      };
myclas::myclas(int x){
                   a=x;
                   }
int myclas::get(){
    return a;
    }
int main(int argc, char *argv[])
{
    myclas ob(120);
    myclas *p;
    p=&ob;
    cout<<"nesneyi kullanan degr: "<<ob.get()<<endl;
    cout<<"isaretciyi kullanan degr: "<<p->get()<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder