I got base class called Worker and two derived classes Merchant and Baker.
class Worker
{
private:
string _name;
public:
Worker(string, string, string, int);
~Worker();
virtual string atributes() = 0;
};
class Merchant : public Worker
{
private:
string _skillLevel;
public:
Merchant(string, string);
string atributes() override;
};
class Baker : public Worker
{
private:
string yearsOfExperiance;
public:
Baker(string, string);
string atributes() override;
};
I have created list list<Workers> Workers
and I am adding there Merchant and Baker objects like this:
void addToList(string name, string atributes, list<Worker>& Worker)
{
if (name == "John")
{
Baker kk = Baker(name, atributes);
Workers.push_front(kk);
}
else if (profesja == "Barack")
{
Merchant pp = merchant(name, atributes);
Workers.push_front(pp);
}
}
The problem is when I try to compile the code the C2259 error occurs. It says
'Worker': cannot instantiate absract class
Can you tell me how to solve this problem, please?