8 Mart 2010 Pazartesi

C++ da Class Tanımlama

//www.ethemsulan.com
#include <cstdlib>
#include <iostream>
using namespace std;
class test{
      public:
             test(int =0);
             void print() const;
      private:
              int x;
      };
test::test(int a){
               x=a;
               }
void test::print() const{
cout<<"x="<<x<<"\nthis->="<< this->x
<<"\n(*this)->x="<<(*this).x<<endl;
     }
int main(int argc, char *argv[])
{
    test object(24);
    object.print();
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder