したがって、基本的には、名前を一意のID番号にマップすることを想定している単純な従業員クラスをいじっています。これが問題です。引数を取らず、名前と従業員 ID のマップを返すメンバー関数を作成したいと考えています。呼び出しを直感的にしたい.employee.map_this() // returns a map
class Employee
{
public:
Employee() = default;
Employee(const string& pname);
Employee& operator=(const Employee&) = delete;
Employee(const Employee&) = delete;
private:
const string name;
static int ID_no;
const string employee_ID;
map<const string, const string> map_this();
};
int Employee::ID_no = 0001;
Employee::Employee(const string& pname) : name(pname), employee_ID(to_string(ID_no))
{
ID_no++;
}
map<const string, const string> Employee::map_this()
{
// How do I do this????
}