Fields
This lesson will go into the details of the member variables or fields of a class.
We'll cover the following
Fields #
As discussed earlier, fields are actually the member variables inside a class. For instance, in a class representing a vending machine, the VendingMachine
class might contain the following fields:
- A
count
of typeint
that stores the count of products available in the machine. - A
capacity
of typeint
that stores the maximum number of products the machine can have. - A
moneyCollected
of typeint
to store the money it has collected. - A
manufacturer
of typestring
to store the name of the manufacturer of the machine.
Get hands-on with 1400+ tech skills courses.