Friday, 28 April 2017

SIMPLE OVERLOADING EXAMPLE

#include<iostream>
using namespace std;
class counter{
private:
int count;
public:
counter(){//default constructor
count=0;
}
counter(int x){
count=x;
}
int getcount(){
return count;
}
void operator-(){//overeloaded operator
cout<<5<<endl;
}

};
int main(){
    counter s2(12);
cout<<"the value of constructor is = "<< s2.getcount();
counter s3;
cout<<endl;
-s3;

}






No comments:

Post a Comment