Home > Back-end >  C, inheritance, virtual functions
C, inheritance, virtual functions

Time:11-22

Defines two classes, vehicles and radar, initial class object given a starting point coordinate, a destination coordinates, to a speed, vehicle class objects over time in this moving back and forth between two points, the vehicle can at any time the output the coordinates of the object, given a initial coordinate radar object and detection range, radar object can output the location information of the vehicle at a certain period, how to abstract from a base class, and that they have a common interface, this interface based on different objects can output the coordinates of the vehicle or output radar detects the information?
Which bosses can say in detail the way of thinking, how to implement? Or give a code, thank you very much

CodePudding user response:

Vehicles, radar, the control class, vehicle movement to inform control class, I moved, location in XXXX, and then whatever. Then the control notification radar, something moved, see if you are interested in him, bala bala, control class can have multiple vehicles and radar

CodePudding user response:

Control the class function can be decomposed, such as the next to a car moving notice speed class, the movement of the mobile car only need to take their own said, regardless of other logic, the speed, is another found that the speed is not the car, but decided by the rules of the road