Return a string in a class
This seems like it would be easy to solve, but im not sure how to do it. I made a class called Person, and in it, I have a getName(). This is what it looks like:
Code:
#include <iostream>
#include <string>
class Person{
public:
std::string setName(std::string name1){
name1 = name2;
}
std::string getName(){
getline(std::string, name2);
}
private:
std::string name2;
};
With the above code I get an error in the getName part. I figured it would be wrong when I was typing it, but I tried anyways. Im not sure how to write that part to where it works. Right now I get this error:
Code:
In member function `std::string Person::getName()':
error: expected primary-expression before ',' token
I have a good feeling the std::string part is whats wrong, but im not positive. Can anyone explain to me the correct way to write that part?