You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
393 B
23 lines
393 B
#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 |