CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
class microbus;
class bus{
public:
int capacity=45; //how many passengers does it take
int fuel; //the capacity of fuel storage
int ticket; //ticket price for each passenger
int consume; //how much fuel does it consume for one km
public:
friend void nprice(bus, microbus ); //function for calculation of new price of ticket after price rise
friend void km(bus, microbus ); //function for calculation of how many km can go with full fuel storage
};
class microbus{
public:
int capacity=20;
int fuel;
int ticket;
int consume;
public:
friend void nprice(bus, microbus);
friend void km(bus,microbus);
};
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run