如果不得已需要全局变量,则使全局变量加前缀 g_(表示 global)。
例如: int g_howManyPeople; // 全局变量 int g_howMuchMoney; // 全局变量
1 #include <iostream> 2 #include<string.h> 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 4 5 using namespace std; 6 //定义双亲(parent)类 7 class parent { 8 char f_name[20]; 9 char m_name[20]; 10 char tel[10]; 11 public: 12 // parent类的构造函数,其带有缺省值 13 parent(