C++
C++
#include <iostream>
using namespace std;
class Person {
public :
int age;
char* name;
};
class Student : public Person {
public :
char* major;
void NewStudent() {
char _name[10];
char _major[10];
cout << "[Add new student]" << endl
<< "- name :";
cin >> _name;
name = _name;
cout <<"- major :";
major = _major;
cout <<"- age :";
cin >> age;
}
};
class MainMenu{
private:
int sel;
public :
int IssueMenu() {
cout << "---------------<MainMenu>---------------"
<< endl <<"1. Add new student" << endl
<< "2. Show all student" << endl << endl
<< "0. Quit" << endl <<
"----------------------------------------"<< endl
<< "Menu >>";
cin >> sel;
return sel;
}
};
class StudentManager {
private :
int index;
Student* SList[50];
public :
bool AddStudent(Student* sp) {
SList[index] = sp;
index++;
return true;
}
void ShowAllStudent(){
for (int i = 0; i <= index; i++) {
cout << SList[i]->name <<"₩t"
<< SList[i]->age << "₩t"
<< SList[i]->major << endl;
}
}
};
int main (void) {
MainMenu mu;
Student st;
cout << mu.IssueMenu() << endl;
st.NewStudent();
cout << st.name << endl <<st.age <<
endl << st.major ;
}
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.