#include <iostream>
#include <string>
using namespace std;
class PermanentWorker
{
private:
char name[100];
int salary;
public:
PermanentWorker(char *name,int money) : salary(money)
{
strcpy(this->name,name);
}
int GetPay() // 여기에 const를 안붙이면에러가남
{
return salary;
}
void ShowSalaryInfo() const
{
cout<< "name :"<<name<<endl;
cout<< "salary:"<<GetPay()<<endl<<endl; // 여기 GetPay() 에 빨간줄이뜸
}
};
주석처리한부분 읽고 이유좀알려주세요
const 함수 내에서는 const 함수가 아닌건 못불러와서 그런거 아닌가요
ShowSalary 함수는 const인데 거기에 const함수가 아닌 GeyPay가 와서 그런 것 같네요.