#include<iostream> #include"string" using namespace std; class student { static int number; string name; public: void set(string str) { name = str; number++; } void print() { cout << name << "-> student are" << number << " numberd\n" << endl; } static int printnumber() { cout << number << " total number" << endl; return 0; } };
int student::number=0; //
void fn() { student s1,s2; s1.set("jerry"); s2.set("randy"); s1.printnumber();
} int main() { student s; s.set("smith"); fn(); s.print(); student::printnumber(); system("pause"); return 0; }
|