#include <cstdlib>
#include <iostream>
using namespace std;
class Student
{
protected:
int Studentid;
char Studentname[20];
char Studentaddress[30];
public:
void Accept()
{
cout << "Please enter the student id: ";
cin >> Studentid;
cout << "Please enter the name of the student: ";
cin >> Studentname;
cout << "Please enter the student address: ";
cin >> Studentaddress;
}
void Display()
{
cout << "Student Information is : "<<endl;
cout << "Student ID: ";
cout << Studentid << endl;
cout << "Name: ";
cout << Studentname << endl;
cout << "Address: ";
cout << Studentaddress << endl;
}
};
class FndEng : public Student
{
protected:
float maths;
float physics;
public:
void FndEngAccept()
{
cout << "Please enter your mathematics marks: ";
cin >> maths;
cout << "Please enter your physics marks: ";
cin >> physics;
}
};
class FndComm : public Student
{
protected:
float accounting;
float management;
public:
void FndCommAccept()
{
cout << "Please enter your accounting marks: ";
cin >> accounting;
cout << "Please enter your management marks: ";
cin >> management;
}
};
void main()
{
class Student : public FndEng
{
void FndEngDisplay()
{
cout << "Your marks are: ";
cout << "Mathematics: ";
cout << maths;
cout << "Physics: ";
cout << physics;
}
}
class Student : public FndComm
{
void FndCommDisplay()
{
cout << "Your marks are: ";
cout << "Accounting: ";
cout << accounting;
cout << "Management: ";
cout << management;
}
}
};
int main(int argc, char *argv[])
{
int ichoice;
cout << "Welcome to curtin foundation program!" << endl;
cout << "Please choose your stream: " <<endl;
cout << "1.Foundation Engineering."<<endl;
cout << "2.Foundation Commerce."<<endl;
cin >> ichoice;
cout << endl;
switch(ichoice)
{
case 1:
{
FndEng Eng;
Eng.Accept();
Eng.FndEngAccept;
Eng.Display();
Eng.FndEngDisplay;
break;
}
case 2:
{
FndComm Comm;
Comm.Accept();
Comm.FndCommAccept;
Comm.Display();
Comm.FndCommDisplay;
break;
}
default:
{
cout << "Please enter only 1 or 2" << endl;
break;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
A C++ programme has only one main function as the start point. You have two.
void main(), which is old style C++ and should be int main().
int main(int argc, char *argv[]), which is fine.
Decide where you actually want the programme to start, and just have one main function.