class - C++: Derived classes, "no matching constructor" error -


i've been working on assignment while. here's instructions:

you design abstract class called employee members given below (make them protected):

data members: char *name, long int id

two constructors: default constructor // intitialize data memebrs default values , copy constructor

methods: setperson (char *n, long int id) //allows user set information each person function called print () // should virtual function, prints data attributes of class. , destructor

also define 2 classes derived class employee, called manager , secretary. each class should inherit members base class , has own data members , member functions well. manager should have data member called degree his/her undergraduate degree (e.g. diploma, bachelor, master, doctor), secretary should have contract (can boolean value 1/0 permanent/temporary).

all member functions of derived class should overrided base class.

write following main() test classes

int main() { employee * p = new manager(“bruce lee”, 0234567, “dr.”); p.print(); secretary p2; p2.setperson(“wilma jones”, 0341256, “permanent”); delete p; p = & p2; p.print(); return 0; } 

this i've come far, i'm pretty sure it's riddled mistakes , arguments , variable types off.

#include <iostream> using namespace std;   class employee{ protected:     char *name;     long int id; public:     employee();     employee(employee&);     void setperson(char * n, long int eid) {         name = n;         id = eid; };     virtual void print(){         cout << "name: " << name << endl;         cout << "id: " << id << endl; }; };  class manager: public employee { protected:     char *degree; public:     void setperson(char * n, long int eid, char * d){         name = n;         id = eid;         degree = d;     };     void print() {         cout << "name: " << name << endl;         cout << "id: " << id << endl;         cout << "degree: " << degree << endl;     }; };  class secretary: public employee { protected:     bool contract; public:     void setperson(char * n, long int eid, string c){         name = n;         id = eid;         if (c == "permanent") contract = true;         else contract = false;     };     void print(){         cout << "name: " << name << endl;         cout << "id: " << id << endl;         cout << "contract: " << contract << endl;     }; };  int main() {     employee * p = new manager("bruce lee", 0234567, "dr.");     p.print();     secretary p2;     p2.setperson("wilma jones", 0341256, "permanent");     delete p;     p = & p2;     p.print();     return 0; } 

i'm getting error on line 62 (the first line of main code):

no matching constructor initialization of manager

i've tried reading similar questions, haven't helped me much. think confusing thing contract being bool value , use of char arguments. guidance @ appreciated.

the error you're getting pretty straight-forward: don't have constructor manager (or employee) takes string, integer (?), , string arguments.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -