#include<iostream>
#include<string>
using namespace std;
class Person2
{
public:
Person2()
{
m_Name = "n";
m_Age = 1;
m_Sex = "s";
cout << "执行了构造函数初始化" << endl;
}
Person2(string name, int age,string sex)
{
m_Name = name;
m_Age = age;
m_Sex = sex;
}
void showInfo()
{
cout << " 姓名:" << m_Name <<" 年龄: "<<m_Age << " 性别: " << m_Sex <<endl;
Output();
}
~Person2()
{
cout << "执行了析构函数" << endl;
}
protected:
string m_Name;
string m_Sex;
int m_Age;
void Output()
{
cout << "执行了output函数" << endl;
}
};
//子类
class Student :public Person2
{
public:
void showInfo1()
{
cout << m_Name<<m_Age << endl;
Output();
}
};
int main()
{
Person2 p5;
Person2 p6("张三", 20, "男");
p6.showInfo();
Student s;
s.showInfo1();
cout << "exis main..." << endl;
system("pause");
return 0;
}

 
	
                                                 VIP会员
VIP会员 购物车
购物车


 私信
                         私信 
                     发表新帖
发表新帖 立即签到
立即签到 查看视频
查看视频
                                
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
                    

 
                







 
                     
                     
					 
						 
						 
						 
						