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
|
101 Discussions
|
Please Login in order to post a comment
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.
Indulge in the exquisite flavors and impeccable hospitality of Bagatelle restaurants in London. Our culinary experts craft delectable dishes using the finest ingredients, from succulent meats to fresh seafood, ensuring a gastronomic delight with every bite. Paired with our warm and attentive service, Bagatelle offers a dining experience that transcends the ordinary, inviting you to savor moments of culinary bliss in the heart of London.
make the definition of get_price() function to -> virtual int get_price() , meaning it can be overridden by derieved class if it got a function definiton in it but default definition is used when no function definition. Thats y when no virtual is used, it returns 50*1 + 1*100 = 150 leading to 250+ 150= 400 but when virtual is used, overriding takes place -> in derieved class 50*bedrooms + 100*bathroom + 100 = 500
Key idea of the solution is the usage of "virtual". If you don't use it in the definition of get_price() function in the base class, then whenever you use a baseclass pointer and try to call the implementation of get_price() in a subclass, you can only get the implementation in the base class, which is a version without adding 100.