C++静态成员的编译 error LNK2001: 无法解析的外部符号 "private: static int AddressBook::m_s_i
程序代码:
//编的一个简单的通讯录的类 对静态成员的运用编译总是报错 class AddressBook { public: AddressBook(string aName = "NULL",int aPhonenum = 0); ~AddressBook(); static int getLength(); static void addLength(); static void decLength(); void setName(string aName); string getName(); void setPhonenum(int aPhonenum); int getPhonenum(); private: string m_strName; int m_iPhonenum; static int m_s_ilength; }; AddressBook::AddressBook(string aName /* = "NULL" */,int aPhonenum /* = 0 */) { m_strName = aName; m_iPhonenum = aPhonenum; } AddressBook::~AddressBook() { --m_s_ilength; }错误是AddressBook.obj : error LNK2001: 无法解析的外部符号 "private: static int AddressBook::m_s_ilength" (?m_s_ilength@AddressBook@@0HA)
求解