previous | index | next

Invoking Non-Default Class Constructors

Non-default constructors are provided arguments just like methods:
  ...
  Item item = new ItemInfo(49.99, "Navy blue");
  cout << "The item's price is " << item->getPrice() << endl;
  cout << "The item's color is " << item->getColor() << endl;
Output:
  The item's price is 49.99
  The item's color is Navy blue

previous | index | next