您的位置:首页 > 其它

第四章作业:4.17:建立一个对象数组,内放6个学生的数据(学号,成绩),用指针向数组首元素,输出第2,4,6个学生的数据。

2015-06-29 23:13 866 查看

#include<iostream> 

#include<string> 

using namespace std; 

class student  { 

public: 

     void show1(); 

       student (string a,double b) 

   {   score=b; 

       name=a; 

    } 

    private: 

        string name; 

       double score; 

}; 

   void student:: show1() 

   { 

    cout<<name<<"   "<<score<<endl; 



    void show(student q) 



    q.show1(); 

}     

int main() 



    student stu[6]={student("小明",67),student("小红",88),student("小芳",70),student("小俊",100), 

        student("小兰",79),student("小军",98)}; 

    for(int i=1;i<6;i+=2) 

    { 

        show(stu[i]); 

    }      return 0; 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: