如题:
#include <iostream>
#include <string>
class Employee {
private:
static unsigned id;
public:
Employee() { m_id = ++id;}
Employee(const std::string &s) { m_id = ++id; m_name = s;}
Employee(const Employee&) = delete;
Employee &operator=(const Employee&) = delete;
unsigned get_id() { return m_id;}
std::string get_name() { return m_name;}
static void init_id() { id = 0;}
private:
unsigned m_id;
std::string m_name;
};
int main() {
Employee::init_id();
Employee a("wu"), b("sun"), c("liu");
std::cout << a.get_id() << " and " << a.get_name() << std::endl;
std::cout << b.get_id() << " and " << b.get_name() << std::endl;
std::cout << c.get_id() << " and " << c.get_name() << std::endl;
}
遇到error:
这是什么原因呢?