Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class ship {
- protected:
- double weight;
- public:
- virtual void input() = 0;
- virtual void print() = 0;
- };
- class jet_boat : ship {
- double max_speed;
- public:
- void input() {
- cout << "Enter weight: ";
- cin >> weight;
- cout << "Enter max speed: ";
- cin >> max_speed;
- }
- void print() {
- cout << "Weight: " << weight << endl;
- cout << "Max speed: " << max_speed << endl;
- }
- };
- class passenger_liner : ship {
- double number_passengers;
- public:
- void input() {
- cout << "Enter weight: ";
- cin >> weight;
- cout << "Enter number of passengers: ";
- cin >> number_passengers;
- }
- void print() {
- cout << "Weight: " << weight << endl;
- cout << "Number of passengers: " << number_passengers << endl;
- }
- };
- int main() {
- jet_boat j;
- j.input();
- cout << endl;
- j.print();
- cout << endl;
- passenger_liner p;
- p.input();
- cout << endl;
- p.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement