jeudi 7 janvier 2021

this error no matching function for call to Employee::Employee()

i think that i doing something wrong when i declare the constructor in the subclass "Manager". i didn't understand if it's an inheritance problem between the two classes.

employee.h

#ifndef EMP_IMP_H_INCLUDED
    #define EMP_IMP_H_INCLUDED
    #include<string>
    
    using namespace std;
    
    class Employee
    {
        private:
            string name;
            int salary;
    
        public:
            Employee(string n,int s){name=n; salary=s;};
            virtual ~Employee() {}
            //GetName();
            //GetSalary();
            //virtual PrintInfo();
    };
    
    class Manager:public Employee
    {
        private:
            int bonus;
    
        public:
            Manager(string n,int s,int b){name=n;salary=s;bonus=b;};
            virtual ~Manager() {};
            //GetBonus();
            //PrintInfo();
    };

#endif // EMP_IMP_H_INCLUDED

main.cpp

#include <iostream>
#include <string>
#include "NODO.h"
#include "EMP_IMP.h"
using namespace std;
int main(){
    Employee *emp1=new Employee (string("ciro esposito",1000));
    Employee *emp2=new Employee(string("Gennaro Espostio"),2000);
    Employee *emp3=new Manager(string("Carmine Espostio"),2000,2000);
    Employee *emp4=new Manager(string("Salvatore Espostio"),3000,3000);  
}

Aucun commentaire:

Enregistrer un commentaire