Is a parking-lot-of-Car a kind-of parking-lot-of-Vehicle?
Nope. I know it sounds strange, but it’s true. You can think of this as a direct consequence of the previous FAQ, or you can reason it this way: if the kind-of relationship were valid, then someone could point a parking-lot-of-Vehicle pointer at a parking-lot-of-Car. But parking-lot-of-Vehicle has a addNewVehicleToParkingLot(Vehicle&) member function which can add any Vehicle object to the parking lot. This would allow you to park a NuclearSubmarine in a parking-lot-of-Car. Certainly it would be surprising if someone removed what they thought was a Car from the parking-lot-of-Car, only to find that it is actually a NuclearSubmarine. Another way to say this truth: a container of Thing is not a kind-of container of Anything even if a Thing is a kind-of an Anything. Swallow hard; it’s true. You don’t have to like it. But you do have to accept it. One last example which we use in our OO/C++ training courses: “A Bag-of-Apple is not a kind-of Bag-of-Fruit.” If a Bag-of-Apple could be passed
Nope. I know it sounds strange, but it’s true. You can think of this as a direct consequence of the previous FAQ, or you can reason it this way: if the kind-of relationship were valid, then someone could point a parking-lot-of-Vehicle pointer at a parking-lot-of-Car. But parking-lot-of-Vehicle has a addNewVehicleToParkingLot(Vehicle&) member function which can add any Vehicle object to the parking lot. This would allow you to park a NuclearSubmarine in a parking-lot-of-Car. Certainly it would be surprising if someone removed what they thought was a Car from the parking-lot-of-Car, only to find that it is actually a NuclearSubmarine. Another way to say this truth: a container of Thing is not a kind-of container of Anything even if a Thing is a kind-of an Anything. Swallow hard; it’s true. You don’t have to like it. But you do have to accept it. One last example which we use in our OO/C++ training courses: “A Bag-of-Apple is not a kind-of Bag-of-Fruit.” If a Bag-of-Apple could be passed