Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is a parking-lot-of-Car a kind-of parking-lot-of-Vehicle?

kind-of
0
Posted

Is a parking-lot-of-Car a kind-of parking-lot-of-Vehicle?

0

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

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123