info changable and unchangable

                Never    
C++
       
#include<iostream>
using namespace std;
class info{
public:
    int age=20;
    void getage(int i){
    age=i;

    }
    void getinfo(){
      cout<<"My name is Thasin."<<endl;
      cout<<"I am "<<age <<" years old."<<endl;
      cout<<"I live in Comilla."<<endl;
      cout<<"I am a male."<<endl;
    }
};
int main(){
info ob1;
ob1.getinfo();

        int c=0,d=0;
cout<<"if you want to change your age press 1."<<endl;
cin>>c;
if(c==1){
        cout<<"input new age.\t";
        cin>>d;
    ob1.getage(d);
    ob1.getinfo();

}
}

Raw Text