what is the error in my code. HELP REQUIRED HERE. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is the error in my code. HELP REQUIRED HERE.

//THIS IS THE CODE BELOW NEED TO KNOW WHAT IS WRONG... // BRINGS AN ERROR SHOWING "INVALID USE OF MEMBER(did you forget thr '&'? " #include<iostream> #include<cstring> #include<string> using namespace std; class EMPLOYEE { public: int Employee_Number; char Employee_Name[25]; int BasicSalary; float IT, NetSalary; public: void get(); void diplay(); void allowance(); void GrossSalary(); }person; void EMPLOYEE::get() { cout<< "Enter the Employee Number: "<< endl; cin >> Employee_Number; cout<< "Enter employee name: "<< endl; cin>> Employee_Name; cout<< "Enter the salary: "<< endl; cin>> BasicSalary; } void EMPLOYEE::allowance() { int allowance; allowance = BasicSalary * 0.12; cout<< "The allowance is : "<< allowance << endl; } void EMPLOYEE::GrossSalary() { float GrossSalary; GrossSalary = BasicSalary - allowance; cout<< "The gross salary is: "<< GrossSalary << endl; } int main() { person.get(); person.allowance(); person.GrossSalary(); }

23rd Oct 2018, 6:46 PM
Dalwadi Tanay
Dalwadi Tanay - avatar
3 Answers
0
You are not defining person. You need something like EMPLOYEE person; before person.get(); in the mainstream method
23rd Oct 2018, 7:05 PM
sneeze
sneeze - avatar
0
i have already defined the person as object. the error is around gross salary = basicsalary - allowance
23rd Oct 2018, 7:11 PM
Dalwadi Tanay
Dalwadi Tanay - avatar
0
It is a really cool bug. You did define person. That is true. The real problem is. You have a method called "allowance" void EMPLOYEE::allowance() and a variable called allowance. int allowance; This confuses the compiler. https://code.sololearn.com/cQ8cvOMi9bB2
23rd Oct 2018, 8:21 PM
sneeze
sneeze - avatar