Quick Question

I have made a little snippet of what my project is essentially based on - except much bigger. I am having a hard to grasping this particular concept. I need to make a car class which inherits the vehicle class and then there must be separate classes such as window, door, engine etc... I need to access those classes through the car class to adjust its "properties"

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
29
#include <iostream>
using namespace std;

class Vehicle
{
	virtual void print() = 0;
};

class Car : public Vehicle
{
	virtual void print();
	Wheel tires[4];
};

class Wheel
{
public:
	int pressure = 0;
	int inflate(int psi)
	{
		pressure = pressure + psi;
	}
};

int main()
{
	//What would I have to put here or anywhere else to increase the pressure of a car object's FIRST tire's pressure
	
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Car : public Vehicle
{
    virtual void print();
    Wheel tires[4];
    static const int MAX_PRESSURE = 100;
public:
    void inflate(int tire)
    {
        tires[i].inflate(MAX_PRESSRE - tires[i].pressure);
    }
};


int main()
{
    Car car;
    car.inflate(1);	
}
Topic archived. No new replies allowed.