getter and setter

#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
So what name do you want person1 to have?
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.