We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Debugging
- Hotel Prices
- Discussions
Hotel Prices
Hotel Prices
Sort by
recency
|
104 Discussions
|
Please Login in order to post a comment
Adding virtual keyword in front of get_price() in Hotel Room is enough.
Adding virtual keyword in front of get_price() in Hotel Room is enough.
class HotelRoom { public: HotelRoom(int bedrooms, int bathrooms) : bedrooms_(bedrooms), bathrooms_(bathrooms) {}
private: int bedrooms_; int bathrooms_; };
class HotelApartment : public HotelRoom { public: HotelApartment(int bedrooms, int bathrooms) : HotelRoom(bedrooms, bathrooms) {}
};
Nah... I didn't know we were playing find the missing keyword. This took me some minutes while I was thinking why it doesn't work when the calculations are actually correct lol.
Im gonna be real with yall, at first when I did this I just created a new vector for apartment rooms... I didn't really understand virtuals at that time so when I came back I was mentally kicking my past self.