I have a project in which I need to get Enum as an input from the user and send it to a constructor.. I searched , didn't find something like this on this website,so here is my Class containing Enums, which compiles:
class Worker {
public:
string myGender;
enum workerType {DIRECTOR, ACTOR, COPYWRITER, PRODUCER} myType;
Worker::Worker(workerType type,string gend)
{
myType = type;
myGender = gend;
}
this is the relevant method from my main class, from which i perform actions, and this one compiles as well:
void MovieIndustry::addWorker(Worker::workerType type, string gend)
{
workers.push_back(Worker(type, gend));
break;
}
From my main I want to get an input like: 0, male
and to add a Worker instance with parameters myType = DIRECTOR myGender = male
I tried this, and it doesn't compile:
#include "MovieIndustry.h" //this is not the problem, works for other funcs
int main() {
MovieIndustry cinema;
int numForWorkertype;
string stringForGender;
cin >> numForWorkertype >> stringForGender;
cinema.addWorker(numForWorkertype ,stringForGender);
return 0;
}
serInterface.cpp:54:64: error: no matching function for call to
‘MovieIndustry::addWorker(int&, std::string&)’
HELP..?