#include<iostream>
using namespace std;
class Counter{
private:
int count;
public:
Counter(){
count = 0;
cout<<"Counter object created:\n";
}
Counter(int i){
cout<<"Counter object created:\n";
count = i;
}
void inc_count( ){
count++;
}
int get_count(){
return count;
}
};
int main(){
Counter c;
Counter c2(2);
Counter c3(7);
for(int i=0; i<3; i++){
c2.inc_count();
}
cout<<"The value after the increment: "<<c2.get_count()<<endl;
for(int i=0; i<4; i++){
c3.inc_count();
}
cout<<"The value after the increment: "<<c3.get_count()<<endl;
}
Comments
Leave a comment