Suppose you have the following hierarchy of objects:
class Vehicle { public: virtual ~Vehicle() {} }; class LandCraft: public Vehicle {}; class Truck: public LandCraft {};
Now we have two expressions:
Truck truck; Vehicle& vehicle = truck;
According to the homework decision, the second expression is not valid. But why? My compiler does not complain at all, and I do not see what should be wrong here.
source share