By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,655 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,655 IT Pros & Developers. It's quick & easy.

Getting error as expected unqualified-id before if .

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. using namespace std;
  3. class teacher{ protected:
  4.     char name[20];
  5.     int integer;
  6.     char qualification;
  7.     int experience;
  8.     int salary;
  9.     public:
  10.         void get(){
  11.             cin>>name>>integer>>qualification>>experience>>salary;
  12.         }
  13. };
  14. class hr{
  15.     protected:
  16.         int increment=0;
  17. };
  18. class totalsalary:public teacher,public hr
  19. {
  20.     int total;
  21.         if(experience>=1 && experience=<3 && qualification=='g')
  22.         increment=increment+1000;
  23.             else    if( experience>1 && experience<3 && qualification=='p')
  24.                 increment=increment+2000;
  25.                     else    if( experience>1 && experience<3 && qualification=='d')
  26.                             increment=increment+3000;
  27.                             else    if( experience>3 && experience<5 && qualification=='g')
  28.                                     increment=increment+4000;
  29.                                 else        if( experience>3 && experience<5 && qualification=='p')
  30.                                             increment=increment+5000;
  31.                                     else            if( experience>3 && experience<5 && qualification=='d')
  32.                                                     increment=increment+6000;
  33.                                         else                if( experience>5  && qualification=='d')
  34.                                                             increment=increment+8000;                                
  35.                                                             total=salary+increment;
  36.                                                             public:
  37.                                                             void show(){
  38.                                                                 cout<<name<<endl<<integer<<endl<<qualification<<endl<<experience;
  39.                                                                 cout<<endl<<salary<<endl<<increment<<endl<<total<<endl;
  40.                                                             }
  41. };
  42. main(){
  43.     totalsalary t;
  44.     t.get();
  45.     t.show();
  46. }
Mar 26 '18 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
All code must be inside a function. The boldface code below is not inside a function.

[code]#include<iostream>
using namespace std;
class teacher{ protected:
char name[20];
int integer;
char qualification;
int experience;
int salary;
public:
void get(){
cin>>name>>integer>>qualification>>experience>>sal ary;
}
};
class hr{
protected:
int increment=0;
};
class totalsalary:public teacher,public hr
{
int total;
if(experience>=1 && experience=<3 && qualification=='g')
increment=increment+1000;
else if( experience>1 && experience<3 && qualification=='p')
increment=increment+2000;
else if( experience>1 && experience<3 && qualification=='d')
increment=increment+3000;
else if( experience>3 && experience<5 && qualification=='g')
increment=increment+4000;
else if( experience>3 && experience<5 && qualification=='p')
increment=increment+5000;
else if( experience>3 && experience<5 && qualification=='d')
increment=increment+6000;
else if( experience>5 && qualification=='d')
increment=increment+8000;
total=salary+increment;

public:
void show(){
cout<<name<<endl<<integer<<endl<<qualification<<en dl<<experience;
cout<<endl<<salary<<endl<<increment<<endl<<total<< endl;
}
};
main(){
totalsalary t;
t.get();
t.show();
}[/CO
Mar 26 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.