parent
5e3d26b9c5
commit
dc13493a45
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef CAR_H
|
||||||
|
#define CAR_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include "tyre.h"
|
||||||
|
#include "driver.h"
|
||||||
|
|
||||||
|
class Car
|
||||||
|
{
|
||||||
|
Tyre tyre{};
|
||||||
|
Driver &driver; // 这里只能是引用或指针,同时必须在初始化列表当中初始化
|
||||||
|
public:
|
||||||
|
Car(Tyre &_tyre, Driver &_driver) : tyre{_tyre}, driver{_driver}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void print()
|
||||||
|
{
|
||||||
|
tyre.print();
|
||||||
|
driver.print();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in new issue