C++ Örnekleri 82 – This Kullanımı

#include <iostream>
#include <conio.h>
using namespace std;

// 100 ile 200 sayısını nesne değişkenlerine atayalım.bunların toplamınıda this i kullanarak gösterelim

class toplama{
      int x,y;
      public:
             toplama(int sayi1,int sayi2){
                       this-> x=sayi1;
                       this-> y=sayi2;
                        }
             int topla(){
                 return this-> x + this-> y;                
                        }
             int goster(){
                 int m;
                 m=this->topla();
                 cout << m;
                 }
      };

main(){
       toplama ob(100,200);
       ob.goster();

       getch();
       return 0;
       }

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir