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
|
105 Discussions
|
Please Login in order to post a comment
Here is Hotel Prices solution in c++ - https://programmingoneonone.com/hackerrank-hotel-prices-solution-in-cpp.html
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.