Suppose you have the following object hierarchy:
class Vehicle {
public:
virtual ~Vehicle() {}
};
class LandCraft: public Vehicle {};
class Truck: public LandCraft {};
Now, we have the two expressions:
Truck truck;
Vehicle& vehicle = truck;
According to a solution to a homework, the second expression is not valid. But why? My compiler doesn't complain at all, and I don't see what should be wrong here.