相关代码 |
|
例3.19 静态数据成员 #include class Student{ static int count; //静态数据成员 int StudentNo; public: Student() { count++; StudentNo=count; } void print() { cout cout } }; int Student::count=0; //给静态数据成员count赋初值 void main() { Student s1; s1.print(); cout Student s2; s1.print(); s2.print(); cout Student s3; s1.print(); s2.print(); s3.print(); cout }
相关资源 |
|