标签:china box 文件中 hang 沟通 color 构造 数据 图片
#include<iostream> #include<string> using namespace std; class Student { public: Student(string pname = "null", int page = 0); void PrintNum(); ~Student(); private: string name; int age; static int num; }; int Student::num = 0; Student::Student(string pname, int page):name(pname),age(page) { num++; } void Student::PrintNum() { cout << "num of student:" << num << endl;; } Student::~Student() { } int main() { Student p1("jibisheng",25); // cout << "num of student:\n"; p1.PrintNum(); Student p2("zhangjie",24); // cout << "\nnum of student:\n"; p1.PrintNum(); Student p3("jijie", 24); // cout << "\nnum of student:\n"; p1.PrintNum(); Student p4("zhangsheng", 24); // cout << "\nnum of student:\n"; p4.PrintNum(); Student p5; // cout << "\nnum of student:\n"; p5.PrintNum(); return 0; }
转:http://blog.chinaunix.net/uid-26983585-id-3308972.html
标签:china box 文件中 hang 沟通 color 构造 数据 图片
原文地址:https://www.cnblogs.com/jibisheng/p/13154262.html