Error message is identifier expected and declaration terminated incorrectly.
//to define a class Employee
#include<iostre am.h>
#include<stdio. h>
#include<string .h>
#include<conio. h>
class cEmp
{
private:
int eid;
char ename[10];
char dname[10];
float sal;
public:
cEmp();
cEmp(int,char*, char*,float);
void accept();
void display();
float getsal();
int getid();
};
cEmp::cEmp()
{
eid=0;
strcpy(ename,"/0");
strcpy(dname,"/0");
sal=0;
}
cEmp::cEmp(int, char*,char*,flo at)
{
int id;
float s;
char n[10],d[10];
eid=id;
strcpy(ename,n) ;
strcpy(dname,d) ;
sal=s;
}
cEmp::void accept() //Error in this line<<<<<<<<<<< <<<<
{
cout<<"Enter empoyee ID:";
cin>>eid;
cout<<"Enter employee name:";
gets(ename);
cout<<"Enter department name";
gets(dname);
cout<<"Enter employee salary:";
cin>>sal;
}
cEmp::void display()
{
cout<<"\nEmploy ee ID:"<<eid;
cout<<"\nEmploy ee name:"<<ename;
cout<<"\nDepart ment name"<<dname;
cout<<"\nEmploy ee salary"<<sal;
}
cEmp::void getid()
{
return eid;
}
cEmp::void getsal()
{
return sal;
}
void main()
{
clrscr();
do
{
cout<<"\t\tMenu ";
cout<<"\n\n\t1. \tDisplay all the employees' info.";
cout<<"\n\n\t2. \tDisplay specific employes' info.";
cout<<"\n\n\t3. \tDisplay employee with max salary.";
cout<<"\n\n\tEn ter choice:";
int n,i,a;
cin>>a;
switch(a)
{
case 1:
for(i=0;i<n;i++ )
c[i].display();
break;
case 2:
cout<<"Enter ID:";
int x;
cin>>x;
for(i=0;i<n;i++ )
if(c[i].getid()==x)
c[i].display();
break;
case 3:
float max=0;
for(i=0;i<n;i++ )
if(c[i].getsal()>max)
max=c[i].getsal();
for(i=0;i<n;i++ )
if(c[i].getsal()==max)
c[i].display();
break;
}
cout<<"\nDo you want to continue?(y/n):";
char y;
cin>>y;
}
while(y=='y');
{
getch();
}
return();
}
//to define a class Employee
#include<iostre am.h>
#include<stdio. h>
#include<string .h>
#include<conio. h>
class cEmp
{
private:
int eid;
char ename[10];
char dname[10];
float sal;
public:
cEmp();
cEmp(int,char*, char*,float);
void accept();
void display();
float getsal();
int getid();
};
cEmp::cEmp()
{
eid=0;
strcpy(ename,"/0");
strcpy(dname,"/0");
sal=0;
}
cEmp::cEmp(int, char*,char*,flo at)
{
int id;
float s;
char n[10],d[10];
eid=id;
strcpy(ename,n) ;
strcpy(dname,d) ;
sal=s;
}
cEmp::void accept() //Error in this line<<<<<<<<<<< <<<<
{
cout<<"Enter empoyee ID:";
cin>>eid;
cout<<"Enter employee name:";
gets(ename);
cout<<"Enter department name";
gets(dname);
cout<<"Enter employee salary:";
cin>>sal;
}
cEmp::void display()
{
cout<<"\nEmploy ee ID:"<<eid;
cout<<"\nEmploy ee name:"<<ename;
cout<<"\nDepart ment name"<<dname;
cout<<"\nEmploy ee salary"<<sal;
}
cEmp::void getid()
{
return eid;
}
cEmp::void getsal()
{
return sal;
}
void main()
{
clrscr();
do
{
cout<<"\t\tMenu ";
cout<<"\n\n\t1. \tDisplay all the employees' info.";
cout<<"\n\n\t2. \tDisplay specific employes' info.";
cout<<"\n\n\t3. \tDisplay employee with max salary.";
cout<<"\n\n\tEn ter choice:";
int n,i,a;
cin>>a;
switch(a)
{
case 1:
for(i=0;i<n;i++ )
c[i].display();
break;
case 2:
cout<<"Enter ID:";
int x;
cin>>x;
for(i=0;i<n;i++ )
if(c[i].getid()==x)
c[i].display();
break;
case 3:
float max=0;
for(i=0;i<n;i++ )
if(c[i].getsal()>max)
max=c[i].getsal();
for(i=0;i<n;i++ )
if(c[i].getsal()==max)
c[i].display();
break;
}
cout<<"\nDo you want to continue?(y/n):";
char y;
cin>>y;
}
while(y=='y');
{
getch();
}
return();
}
Comment