Final II Flashcards
(228 cards)
An object consists of 3 things:
- Name
- Member Data
- Member Functions
An objects name is:
The variable name we give it.
Member data is:
The data that describes an object; Attributes, or the state of the object.
Member functions are:
Behavior aspects of an object (functions related to the object itself)
What is an object?
An encapsulation of data along with functions that act upon that data.
What is a class?
A blueprint for building objects; A user defined type.
A class description consists of:
A declaration and a definition. Usually split into separate files.
An object is a single instance of:
A class. You can create many objects from the same type of class.
What does DDU stand for?
Declare, Define, Use.
Declare (DDU)
Declaration of class (usually) in a header file; Gives an interface.
A variable declaration gives:
The type
A function declaration:
Tells how to use it, without bothering with how it works.
A class declaration:
Shows what an object will look like and what its available functions are, implementation details are not needed.
Define (DDU)
Definition of class members in implementation file.
T/F
The definition of a class doesn’t need to be seen by the user of the class (interface)?
True
A function definition:
The code that makes a function work (the function body)
A class definition:
Consists of definitions of its members.
Use (DDU)
Usage of class by building objects, through its interface (declaration).
The user of a function is:
A programmer, who makes calls to the function (without needing to know implementation details)
The user of a class is:
A programmer, who uses it by creating objects and calling the available functions for those objects.
3 Protection (access) levels in a class:
1) Public
2) Private
3) Protected
Public:
Can be accessed from inside or outside of the object.
Private:
Can only be used by the object itself.
Protected:
Protection label for use in base/derived classes; Members declared as protected can be accesses by the class itself and by derived classes only (not anywhere else)