Chapter 7: Introduction to Classes and Objects

73 flashcards · Programming Languages · by Gabriella Torres

  1. An ______________ is a general model of something. It is a definition that includes only the general characteristics of an object without the details that characterize specific instances of the object.

    abstraction

  2. To use any data type you need to know just two things about it:

    what values it can hold and what operations apply to it.

  3. _______ describes any data type whose implementation details are kept separate from the logical properties needed to use it.

    Abstract data type (ADT)

  4. The ADT term is used to refer to ____.

    data types created by the programmer

  5. __________ is a method of writing software centered on the procedures, or functions, that carry out the actions of the program.

    Procedural programming

  6. _______ is a software entity that combines both data and the procedures that work with it in a single unit.

    An object

  7. An object's data items are also referred to as its _______.

    attributes

  8. An object's data items are stored in __________.

    member variables.

  9. The procedures that an object performs are called its ___________.

    member functions

  10. This bundling of an object's data and procedures together is called ________.

    encapsulation

  11. The procedures that an object performs are called ________.

    methods

  12. _______ refers to an object's ability to hide its data from code outside the object.

    Data hiding

  13. Only the object's _______________ can directly access and make changes to its data.

    member functions

  14. In C++, that class is the _______ primarily used to create objects.

    contstruct

  15. A _______ is a programmer-defined data type that describes what objects of the class will look like when they are created.

    class

  16. To create your own class, you must write a __________.

    class declaration

  17. The general format of a class declaration:

    class ClassName // Class declaration begins with { // the key word class and a name. Declarations for class member variables and member funcitons go here. }; // Notice the required semicolon

  18. The first step of building a class:

    Determine what member variables and member functions the class should have.

  19. The second step of building a class:

    is to write the class declaration. This tells the compiler what the class includes.

  20. Class with private and public keywords:

    class Circle { private: double radius; public: void setRadius(double r) { radius = r; } double calcArea() { return 3.14 * pow(radius, 2); } };

  21. ________ designate who can access various members of the class.

    Access specifiers

  22. A _______ variable can be accessed by functions outside the class, and a _______ function can be called by functions outside the class.

    public member, public member

  23. A _______ variable can only be accessed by a function that is a member of the came class, and a _______ function can only be called by other functions that are members of the class.

    private member, private member

  24. If you omit the words public and private altogether, everything would have defaulted to being ______.

    private

  25. Member data is usually made ______ to safeguard it.

    private

  26. True/False: It does not matter whether we list the private or public members first.

    True

  27. Each object created from a class declaration is called an ______.

    instance

  28. Public members of a class object are accessed with the _________.

    dot operator

  29. Defining a class object is called _______ the class.

    instantiating

  30. An example of using the dot operator:

    cout << city.length() << endl;

  31. Member functions, just like regular functions can be passed ________ when they are called if they have been defined to accept _________.

    arguments, arguments

  32. An object's member variables are usually declared to be ________.

    private

  33. If an object's member variable were declared to be ________, it also could be accessed from outside the class by using the __________.

    public, dot operator

  34. A function like this, that uses the value of a class variable but does not change it, is known as a(n) __________.

    accessor

  35. A member function like this, which stores a value in a member variable or changes its value, is known as a(n) _________.

    mutator

  36. Some programmers refer to mutators as _________ or _________ because they set the value of a class variable.

    set functions, setter functions

  37. Some programmers refer to accessors as ________ or _________ because they just retrieve or use the value.

    get functions, getter functions

  38. When a class function is defined within the class declaration itself, it is called a(n) _________.

    inline function

  39. ________ OR definition provides the actual code that determines the behavior of the function.

    Function implementation

  40. The :: is called the ________. It is needed to indicate that these are class member functions and to tell the compiler which class they belong to.

    scope resolution operator

  41. It is common to name a(n) ________ with the word ________ followed by the name of the member variable whose value it is _________.

    mutator, set, setting

  42. It is common to name a(n) ________ with the word ________ followed by the name of the member variable whose value it is ________ if all it does is return the value stored in the variable.

    accessor, get, getting

  43. When the value of an item is dependent on other data and that item is not updated when the other data is changed, we say that the item has become ________.

    stale

  44. A number of special items, such as the address to return to when the function has finished executing and the values of the function arguments, must be stored in a section of memory called the ________.

    stack

  45. This is why only a function with ________ of code should be written as an ________.

    very few, inline function

  46. A ________ is a member function that is automatically called when a class object is created.

    constructor

  47. If the programmer does not write a constructor, C++ ________.

    automatically provides one

  48. Most often programmers use a constructor to ________ an object's member variables.

    initialize

  49. A constructor looks like a regular function except that its name _________ as the name of the class it is a part of. This is how the compiler knows that a particular member function is a constructor.

    must be the same

  50. A constructor is ________ to have a return type.

    not allowed

  51. Here's how the function header for the demo constructor would look like if we defined it outside the class.

    Demo::Demo() // Constructor { cout << "Now the constructor is running.\n"; }

  52. Just like other functions, class member functions may be ________.

    overloaded

  53. As long as each constructor has a _________, creating a unique signature, the compiler can tell them apart.

    different list of parameters

  54. In C++ when an object is defined using the default constructor, instead of passing arguments, there ________ be any paratheses.

    must not

  55. If you do not have a default constructor, and the program tries to create an object without passing any arguments, ________.

    it will not compile

  56. A constructor which has no parameters is called a ________.

    default constructor

  57. If the programmer doesn't write any constructors for a class, the compiler ________ a default constructor for it.

    automatically creates

  58. When the programmer writes one or more constructors, even ones that all have parameters, the compiler ________ create a default constructor.

    does not

  59. In a process known as ________, the compiler replaces every call to the function with the actual code of the function itself. If the function is called from multiple places in the program, the entire body of its code will be inserted multiple times, increasing the size of the program.

    inline exansion

  60. A ________ is a special public member function that is automatically called to construct a class object when it is created.

  61. A class may have many constructors but can have ________ default constructor.

    only one

  62. A(n) ________ is a list of member variables with their initial values that appear after the constructor heading and before the opening brace of the body.

    member initialization list

  63. The member initialization list includes:

    the name of each variable to be initialized, followed by its initial value enclosed in parentheses .

  64. When a constructor has a member initialization list, the initializations take place ________ any statements in the body of the constructor execute.

    before

  65. You can initialize member variables when they are defined inside the class declaration, this is known as ________.

    in-place initialization

  66. Example of in-place initialization: This gives the variables initial default values for every object of the class that is created. If a program wants to override them, the object can be created using a constructor that accepts arguments.

    class Rectangle { private: double width = 0.0; double length = 0.0; public: // Public member functions go here ... };

  67. It is possible for one constructor to call another constructor in the same class, this is known as ________.

    constructor delegation

  68. A(n) ________ is a member function that is automatically called when an object is destroyed.

    destructor

  69. Destructors are ________ with the same name as the class, preceded by a tilde character (~).

    public member functions

  70. Like constructors, destructors have _________.

    no return type

  71. Destructors ________ accept arguments, so they ________ a parameter list.

    cannot, never have

  72. There can be ________ destructors.

    only one