5-2-1.cpp

来自「学习c++的ppt」· C++ 代码 · 共 23 行

CPP
23
字号
#include <iostream.h>
#include <string.h>
class  Student {
     private:
            int       iNo;
            char    sName[10];
            float    fEng,fMath, fCmp;
      public :                    
            Student(int no, char  *sn,  float  e,  float m, float c)
            {    
                  iNo = no; 
                  strcpy(sName, sn);
                  fEng = e; fMath = m; fCmp = c;
                  cout<< "姓名:" << sName << " -学生的构造函数被调用"<<endl;
            }
            float  GetAvg(); 
            float  GetTotal();
} ;
void main()
{   Student  std1(1001, "zhang", 77, 89, 82);
    Student  std2(1002, "wang", 87, 92, 78);
}

⌨️ 快捷键说明

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