#include #include class Drink { public: Drink(int cost) { this->cost = cost; } int get_cost(void); private: protected: int cost; }; int Drink::get_cost(void) { return cost; } class Juice : public Drink { public: Juice(int shelf, int cost) : Drink(cost), shelf(shelf) { std::cout << "got called\n"; } int get_shelf(void); private: int shelf; protected: }; int Juice::get_shelf(void) { return shelf; } int main(int argc, char **argv) { Juice *dubjuice = new Juice(1, 5); std::cout << dubjuice->get_cost() << std::endl; std::cout << dubjuice->get_shelf() << std::endl; Juice ref = *dubjuice; std::cout << ref.get_cost() << std::endl; std::cout << ref.get_shelf() << std::endl; return 0; }