grade.h
#ifndef GRADE_H#define GRADE_H#include#include using namespace std;class grade{ public: struct student { string name; int score; }; void menu(); void init(); void inputScoreAndName(); void display(); private: vector vt; //struct student}; #endif //不要忘记
grade.cpp
#include"grade.h"#includeusing namespace std;void grade::init(){}void grade::menu(){ int t; cout<<"input 1--4 to select program"< >t; switch(t) // 有括号 { case 1: cout<<"input Name and Score"< >st.name; if(!cin) return; //cin 作为循环判断的条件。注意他的位置是在第一个cin>>之后。 cout<<"1"< >st.score; cout<<"2"<
main.cpp
#include#include #include using namespace std;int main(){ grade grd; while(1) //一直循环 grd.menu();};