⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p311.cpp

📁 谭浩强 《C++ 程序设计》第三版的部分课后练习题源码
💻 CPP
字号:
#include<iostream>
#include<string>
using namespace std;
class Student
{
      public:
             Student(int a,string b,float c)
             {       num=a;
                     name=b;
                     score=c;
                         
             }
             void display();
      private:
              int num;
              string name;
              float score;
      };
      
void Student::display()
{
     cout<<"the number is: "<<num<<endl;
     cout<<"the name is :"<<name<<endl;
     cout<<"the score is :"<<score<<endl; 
     
     }
     
int main()
{
    Student std[5]={
            Student(101,"wang",90),
            Student(102,"zhang",91),
            Student(103,"Li",92),
            Student(104,"song",94),
            Student(105,"lin",95)
                   };
    Student *p=std;
    int n;
    for(n=0;n<5;n++,n++,p++,p++)
            p->display();
    system("pause");
    return 0;
    
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -