טוב אז ככה אני משתגע כבר יום שלם.
#ifndef EMPLOYEE_H_ #define EMPLOYEE_H_ #include <string> using namespace std; class Employee { public: Employee(); virtual ~Employee(); virtual void printEmployeeDetails() = 0; virtual void printType() = 0; virtual string getFirstName() = 0; virtual string getLastName() = 0; int getSalary() const; void setSalary(int salary); protected: int salary; }; class Worker:public Employee { string TypeWorker; // 0= worker string FirstName; string LastName; public: Worker(string type,string firstName,string lastName,int Salary); void printEmployeeDetails(); void printType(); string getFirstName(); string getLastName(); #endif /* EMPLOYEE_H_ */
|
/* * Employee.cpp * * Created on: 16/12/2010 * Author: yariv-h */#include "Employee.h" Employee::Employee() { // TODO Auto-generated constructor stub } Employee::~Employee() { // TODO Auto-generated destructor stub } Employee::setSalary() { salary=this.salary; } Employee::getSalary() { return salary; } Worker::Worker() { TypeWorker=type; //setting the type FirstName=firstName; //setting the First Name LastName=lastName; //setting the Last Name setSalary(Salary); //setting the salary }
Worker::printType() { return TypeWorker; } Worker::printEmployeeDetails() { cout<<"-------------------------------------"<<endl; cout<< getFirstName()<<" "<<getLastName<<endl; cout<<"Status: " << printType() <<endl; cout<<"Salary: " << getSalary() <<endl; cout<<"-------------------------------------"<<endl; } Worker::getFirstName() { return FirstName; } Worker::getLastName() { return LastName; }
|
עכשיו נניח ומוחקים את כול ההורשה של ה WORKER גם ב HEADER וגם ב CPP
ומשאירים רק את ה EMPLOYEE
האקליפס נותן לי שני אררוים
ב HEADER
וגם ב CPP
בשורות האלו
int getSalary() const;*** candidate is: int Employee::getSalary() const void setSalary(int salary); *** candidate is: void Employee::setSalary(int) Employee::setSalary() { salary=this.salary; } *** prototype for ‘int Employee::setSalary()’ does not match any in class ‘Employee’ Employee::getSalary() { return salary; } *** prototype for ‘int Employee::getSalary()’ does not match any in class ‘Employee’
|
איך אני יכול לסדר את זה??
ניסיתי כבר יום שלם לחפור באינטרנט
אין אפשרות לשנות את החתימות של הפונקציות ב HEADER זה מה שקיבלנו בעבודה..
תודה!
