摘要:
——类的所有对象共同一个静态数据成员,只创建一个静态数据成员副本 class StringBad { private: char *str; int len; static int num_strings; // 声明静态数据成员 public: ... }; 静态数据成员在类声明中声明 int S 阅读全文
摘要:
——能够访问类的私有成员的非成员函数 创建友元: 将其原型放在类声明中,并在原型声明前加上关键字friend friend Time operator *(double m, const Time &t); // goes in class declaration operator*()函数不是成员 阅读全文
摘要:
——可用于存储多种数据类型数据,但只能同时存储其中一种的一个值 union one4all { int int_val; long long_val; double double_val; }; one4all pail; pail.int_val = 15; // store an int cou 阅读全文