Program Crashing

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  #include<iostream>
using namespace 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();
}

		
Last edited on
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.
Topic archived. No new replies allowed.