I am getting an error
error: cannot allocate an object of abstract type 'myClass'
I have made made up a small sample to demonstrate my error. Below is the code. (includes and #ifndef stuff is not included)
person.h
class Person{
public:
virtual std::string getRole() = 0;
};
employee.h
class Employee:public Person{
std::string getRole();
};
workplace.h
class Workplace{
public:
void setPeople(std::vector<Person> p);
private:
std::vector<Person> people;
};
workplace.cpp
void Workplace::setPeople(std::vector<Person> p){
people = p;
}
employee.cpp
std::string Employee::getRole(){
return "Generic Employee";
}
The error I am getting from this example is:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_construct.h:80: error: cannot allocate an object of abstract type ‘Person’ person.h:7: note: because the following virtual functions are pure within ‘Person’: person.h:9: note: virtual std::string Person::getRole()
Thanks in advance.