Hi all, I'm trying to write a little program that makes use of derived classes but it doesn't work and I don't know why. It's not very meaningful, it just does some monitor printing. Just to figure out how to connect the various .h and .cpp files.
Can you help me? Thanks
> Sensor is derived from Robot
that makes no sense.
1 2
Sensor s;
s.MoveForward();
that makes no sense.
dictionary wrote:
sensor
<hardware> An electronic device used to measure a physical quantity such as temperature, pressure or loudness and convert it into an electronic signal of some kind (e.g a voltage).
Public inheritance models specialization. As such, publicly deriving Sensor from Robot indicates that a Sensor is a specialized kind of Robot, which is probably nonsense in a typical model
Instead it is more likely that a Robot is associated with or contains one or more Sensors.
Thank you! You're right, the program is tiny because I have to learn. Splitting the file into several files was how I needed to figure out how to connect them. In the future I could have many classes each with its own .h and a .cpp.I wrote this example program that doesn't make much sense, of course, just to understand how to connect the various files because around the network I have not found anything like that.
Thanks again and Happy New Year! :)
pische