Member
C++
#include <iostream>
using namespace std;
class Member {
protected :
int id;
char* name;
int age
int guardID = -1;
public :
Member() {
name = new char[100];
cin >> id >> name >> age;
if (age < 19) cin >> guardID;
}
};
class Adult : public Member{
public :
friend ostream& operator<< (ostream& os, const Adult adt);
};
ostream& operator<< (ostream& os, const Adult adt) {
os << adt->id << adt->name << adt->age << endl;
return os;
}
class Underage : public Member {
private :
Member* guardian;
public :
Underage
friend ostream& operator(ostream& os, const Underage& uda)
}
ostream& operator<< (ostream& os, const Underage& uda) {
os << uda.id << uda.name << uda.age << uda.guardian->id << uda.guardian->name
<< uda.guardian->age << endl;
}
template <typedef T>
class Array {
private :
T* arr[100];
int arrlen;
public :
void InsertArray() {
arr[arrlen] = new Member();
arrlen++;
}
void ShowAllArray() {
for (int i = 0; i < len; i++)
cout << arr[i];
}
~Array () {
delete []arr;
}
};
class MemberManager{
private :
Array<Member> mList;
public :
void InsertMember() {
mList.InsertArray();
}
void ShowAllMember() {
mList.ShowAllArray();
}
};
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.