getter and setter

Mar 2, 2018 at 1:18pm
#include <iostream>

using namespace std;
class fool
{
private:
string name;
public:
string getname(){return name;}
void setname(string n){name=n;}
};
int main()
{
fool person1;
person1.setname(m);
cout<<person1.getname();
}
please find the error ...it is probably in the main function
Mar 2, 2018 at 1:27pm
So what name do you want person1 to have?
Mar 2, 2018 at 3:24pm
1) Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

2) In main, you're trying to use a variable called m, but you haven't defined that variable anywhere. You should read the error messages that your compiler is giving you, because I'm sure it's already told you that.
Topic archived. No new replies allowed.