Hi guys!
I am a beginner and I just started working on C++. I made this code but it has been crashing and I cant find the problem. Can somebody please help me.
#include<iostream>
usingnamespace std;
class student
{
private:
int age,rollno;
string name;
public:
void setage()
{
int a;
cout<<"Enter Age Of Student:"<<endl;
cin>>a;
age=a;
}
getage()
{
cout<<age<<endl;
}
void setname() //setters are used to set values from user into variables
{
string s;
cout<<"Enter Name Of Student:"<<endl;
cin>>s;
name=s;
}
string getname()
{
cout<<name<<endl;
}
};
int main()
{
student S1;
S1.setname();
S1.setage();
S1.getname();
S1.getage();
}
Really that program shouldn't even compile. If it does I suggest you get a better compiler, otherwise I suggest you fix all the compile errors and warnings before you try to run the program.