By default, the members of a class can only be accessed from within the class — they are said to have private access.
For methods to be accessible from outside the class, they need to be declared public.
class ItemInfo { public: double getPrice() { return price; } string getColor() { return color; } private: double price; string color; }; |