59
lab6/18.cpp
Normal file
59
lab6/18.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class BasicInfo {
|
||||
private:
|
||||
char name[30];
|
||||
uint enrollment;
|
||||
char gender;
|
||||
|
||||
public:
|
||||
void getData();
|
||||
void putData();
|
||||
};
|
||||
|
||||
void BasicInfo::getData() {
|
||||
cout << "Name: ";
|
||||
cin >> name;
|
||||
cout << "Enrollment: ";
|
||||
cin >> enrollment;
|
||||
cout << "Gender: ";
|
||||
cin >> gender;
|
||||
}
|
||||
void BasicInfo::putData() {
|
||||
cout << "Name: " << name << endl
|
||||
<< "Enrollment: " << enrollment << endl
|
||||
<< "Gender: " << gender << endl;
|
||||
}
|
||||
|
||||
class PhysicalFit : public BasicInfo {
|
||||
uint height;
|
||||
uint weight;
|
||||
|
||||
public:
|
||||
void getData();
|
||||
void putData();
|
||||
};
|
||||
|
||||
void PhysicalFit::getData() {
|
||||
cout << "Weight (in kg): ";
|
||||
cin >> weight;
|
||||
cout << "Height (in cm): ";
|
||||
cin >> height;
|
||||
}
|
||||
|
||||
void PhysicalFit::putData() {
|
||||
cout << "Weight (in kg): " << weight << endl
|
||||
<< "Height (in cm): " << height << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
PhysicalFit x;
|
||||
x.BasicInfo::getData();
|
||||
x.getData();
|
||||
|
||||
x.BasicInfo::putData();
|
||||
x.putData();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user