Please help explain these errors

I cannot figure out where I went wrong here. Please help

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
 #include <iostream>
#include <string>
using namespace std;


class student {
	private:
		string name;
		int ID;

	public:
	void setName (string n){
		name=n;
	
	}
	void setID (int identify){
		ID=identify;
	
	}
	void printData (){
		cout<<name<<"\t"<<ID<<endl;
	}
}

void main()
{ 
	int num;
	student *p;
	cin>>num;
	p=new student [num];

	for (int i=0; i<num; i++){
		string a;
		cin>>a;
		p[i].setName(a);
		int b;
		cin>>b;
		p[i].setID(b);
		p[i].printData();
	}
}


These are the errors:
1>c:\users\nisreen\documents\visual studio 2010\projects\hw1\hw1\hw1.cpp(25): error C2628: 'student' followed by 'void' is illegal (did you forget a ';'?)

1>c:\users\nisreen\documents\visual studio 2010\projects\hw1\hw1\hw1.cpp(26): error C3874: return type of 'main' should be 'int' instead of 'student'

The return type of main cannot be int :/ These make no sense to me.

(25): error C2628: 'student' followed by 'void' is illegal (did you forget a ';'?)

Line 25 starts with keyword void. Directly before it is class student on line 6.

What is the last character on a class definition? In other words, the line 23 is missing something.
And second one means that you did not write your main function correctly. By C++ International Standard main() shall return int.
What is missing from line 25? I don't get it. How do I fix this?

Also how can the main function return int if it has to be void? :/
if it has to be void
It has to be int, not void.

What is missing from line 25?
Not line 25, line 23.
Look again into how to properly define class. Mainly at last line of class definition.
Topic archived. No new replies allowed.