Hey guys,
So I've been working on a program that takes a student id and name but however I got a weird error saying:
error: expected ‘(’ before ‘.’ token
error: expected ‘{’ before ‘.’ token
and it occurs around the name_first(firstName), name_.second(lastName)
. I'm having trouble to get the pairs working.
typedef std::pair<std::string, std::string> Name;
class Student {
public:
explicit Student(const std::string& id, const std::string& firstName, const std::string& lastName)
: id_(id), name_.first(firstName), name_.second(lastName){
if(!isValidId(id) || !isValidName(name_)){
throw "Student::Student(const string&, const string&, const string&): invalid input.";
}
}
private:
std::string id_;
Name name_;
}
Can anybody help me? Thanks.