2012年12月10日

c++ 静态成员

摘要: 静态成员的需要性: 有些属性是类中所有对象共有的。 如果放在全局变量中,则它们在类的外边,既不安全,又影响了重用性。使用: 像成员有数据成员和成员函数之分一样,静态成员也有静态数据成员和静态数据成员函数之分,静态成员用“static”声明。eg:多文件程序实现结构//student.h的定义class Student{ public: Student(char *pName="no name"); ~Student(); static int number();//静态成员函数 protected: static int noOfStudents; ... 阅读全文

posted @ 2012-12-10 10:28 主人的成长 阅读(141) 评论(0) 推荐(0)

导航