13 Nisan 2010 Salı

C++ ile Sınıf(Class) ve this Örneği

//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<<this->x<<endl<<(*this).x<<endl;
     }
int main(int argc, char *argv[])
{
    test nesne(12);
    nesne.print();
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder