
#include <iostream>
using namespace std;
class Person
{
private:
string m_name;
public:
Person(string name)
{
m_name=name;
}
void sayhello()
{
cout << "hello i'm " << m_name << endl;
}
string getname()
{
return m_name;
}
};
int main()
{
Person p1=Person("eric clapton");
p1.sayhello();
cout << p1.getname() << endl;
return 0;
}
메인 함수에서 마지막줄 getname 앞에는 p.이 왜 붙는 건가요?
