第四章课后练习题第17题



                     Stu[0]  (01,99)   p

                     Stu[1]  (02,98)   p++

                     Stu[2]  (03,97)   

Student

                     Stu[3]  (04,96)   p=p+2

                     Stu[4]  (05,95)   

                     Stu[5]  (06,94)   p=p+2

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、#include<iostream>
using namespace std;
class Student{
public:
 void set(int i,int s)
 {id=i;
 score=s;
 }
 void show1()
 {cout<<"第2个学生的数据为:"<<id<<" "<<score<<endl;;
 }
 void show2()
 {cout<<"第4个学生的数据为:"<<id<<" "<<score<<endl;;
 }
 void show3()
 {cout<<"第6个学生的数据为:"<<id<<" "<<score<<endl;;
 }
private:
 int id;
 int score;
};
int main()
{Student stu[6];
Student *p;
stu[0].set(01,99);
stu[1].set(02,98);
stu[2].set(03,97);
stu[3].set(04,96);
stu[4].set(05,95);
stu[5].set(06,94);
p=stu;
p++;
p->show1();
p=p+2;
p->show2();
p=p+2;
p->show3();
return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值