C++作业4.17

来源:互联网 发布:什么叫软件开发 编辑:程序博客网 时间:2024/06/05 22:39
#include<iostream>
#include<string>
using namespace std;


class student
{
public: 

student(int num1,float score1)
{
num=num1;
score=score1;
}
void print()
{
cout<<num<<" "<<score<<endl;
}
private:
int num;
float  score;
};


int main()
{
student *p;
student a[6]={
student(01,98),
student(02,85),
student(03,90),
student(04,100),
student(05,84),
student(06,97)
};
p=a;
    p++;
p->print();
p=p+2;
p->print();
p=p+2;
p->print();
return 0;

};

程序运行结果:

2 85

4 100

6 97

0 0
原创粉丝点击