当前位置: 移动技术网 > IT编程>开发语言>C/C++ > C++类的继承

C++类的继承

2019年06月22日  | 移动技术网IT编程  | 我要评论

贪官被查时仍敛财,钩弋夫人,山东旅游人才网

 1 #include<iostream>
 2 using namespace std;
 3 double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};
 4 class test{
 5     //基类
 6     public:
 7     int data[4][4];
 8     void fun_test(char a)
 9     {
10         cout<<a<<endl;
11     }
12     
13 };
14 //类的继承
15 class test1:public test{
16     
17 };
18 int main()
19 {
20     int temp;
21     test *p=new test;//定义一个对象指针,访问类公有成员
22     p->fun_test('p');
23     temp=p->data[2][2]=5;
24     
25     cout<<temp<<endl;
26     cout<<"class test1:public test"<<endl;
27     test1 test1;//定义一个对象
28     test1.fun_test('e');
29     delete p;//释放
30 }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网