Header file for base class
Implementation file for base classCode:#ifndef EMPLOYEE_H #define EMPLOYEE_H #include <string> using namespace std; class Employee { public: Employee(string Name="", int ID=0, char Class=' ', float Profit=0); virtual ~Employee(); int getID(); char getClass(); float getProfit(); void setName(string n); void setID(int id); void setClass(char c); void setProfit(float s); virtual void display(ostream & out) const; protected: string myName; int myID; char myClass; float myProfit; private: }; inline ostream & operator << (ostream & out, const Employee & p) { p.display(out); return out; }
Implementation file for derived classCode:#include "Employee.h" #include <string> using namespace std; Employee::Employee(string Name, int ID, char Class, float Profit) :myName(Name), myID(ID), myClass(Class), myProfit(Profit) { } Employee::~Employee() { //dtor }; int Employee::getID() { return myID; }; char Employee::getClass() { return myClass; }; float Employee::getProfit() { return myProfit; }; void Employee::setName(string Name) { myName=Name; } void Employee::setID(int ID) { myID=ID; } void Employee::setClass(char Class) { myClass=Class; } void Employee::setProfit(float Profit) { myProfit=Profit; } void Employee::display(ostream & out) const { out << "Name:" << myName << endl << "ID#" << myID <<endl << "Class:" << myClass << endl << "Profit:" << myProfit << endl; }
When I try to build my code I am getting some errors related to the overloading of my '<<' operator. error: no match for 'operator<<' in 'out << "Salary:$"'|, and error: 'endl' was not declared in this scope| which i believe is related. If someone could help me out with this it would be greatly appreciated. THANK YOU!Code:#include "Chef.h" #include <string> using namespace std; Chef::Chef(string Name, int ID, char Class, float Profit, string Expertise):Employee(Name,ID,Class,Profit),myExpertise(Expertise) { //ctor } Chef::~Chef() { //dtor } string Chef::getExpertise() { return myExpertise; } void Chef::setExpertise(string Expertise) { myExpertise=Expertise; } float Chef::Calc_Sal() { float x=getProfit(); x*=.2; x+=10000; return x; } void Chef::display(ostream & out) const { Employee::display(out); out << "Salary:$" << Calc_Sal() << endl << "Expertise:" << myExpertise << endl; }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.