#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include"Student.cpp"
void main()
{
clrscr();
int choice;
student s;
cout<<"MCA EXAM MANAGEMENT SYSTEM"<<endl<<endl
<<"1. Login"<<endl
<<"2. Register"<<endl;
cin>>choice;
switch(choice)
{
case 1 : clrscr();
cout<<"1. Student Login"<<endl
<<"2. Teacher Login"<<endl;
cin>>choice;
if(choice==1)
{
s.studentLogin();
cout<<endl<<"back to main";
}
else if(choice==2)
{
//Call to login function of teacher class
}
else
cout<<"Invalid choice"<<endl;
break;
case 2: clrscr();
cout<<"1. Student Register"<<endl
<<"2. Teacher Register"<<endl;
cin>>choice;
if (choice==1)
{
//Call to register function of student class
}
else if(choice==2)
{
//Call to register function of teacher class
}
else
cout<<"Invalid choice"<<endl;
break;
default: cout<<"Invalid choice"<<endl;
break;
}
getch();
}
I'm creating an object s of the class "student" which is imported in the file "Main.cpp". Here's what goes wrong with the code
- Login
- Register
enter 1
- Student Login
- Teacher Login
enter 1 (This invokes the studentLogin() method of the class student using "s" object)
The method executes successfully and then returns to the switch case.
Now "back to main" is printed.
After this, on pressing any key, the compiler hangs and I have to force quit.
I tried to find out the problem and it seems to the "s.studentLogin()" method call. When I comment that statement, the code doesn't break. Why is this happening?