Chapter 13 - OOP Class 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Members of a class object are accessed with the

dot operator.

Objects in an array are accessed with ___, just like any other data type in an array.

subscripts

The constructor function always has the same name as

the class

For the following code, which statement is not true? class Point{ private: double y; double z; public: double x; };

z is available to code that is written outside the class

a C++ class is similar to one of these.

structure

This directive is used to create an "include guard," which allows a program to be conditionally compiled. This prevents a header file from accidentally being included more than once.

#ifndef

When you dereference an object pointer, use the

-> operator

What is the output of the following program? #include <iostream> using namespace std; class TestClass{ public: TestClass(int x){ cout << x << endl;} TestClass(){ cout << "Hello!" << endl;} }; int main(){ TestClass test; return 0; }

Hello!

The process of object-oriented analysis can be viewed as the following steps:

Identify objects, then define objects' attributes, behaviors, and relationships

Class declarations are usually stored here

In their own header files

This is automatically called when an object is destroyed.

destructor function

In OOP terminology, an object's member variables are often called its ___, and its member functions are sometimes referred to as its behaviors, or ___.

attributes, methods

When a member function is defined outside of the class declaration, the function name must be qualified with the:

class name, followed by the scope resolution operator

A ___ is a member function that is automatically called when a class object is ___

constructor, created

A class is a(n) ___ that is defined by the programmer.

data type

In a procedural program, you typically have ___ stored in a collection of variables, and a set of ___ that perform operations on the data.

data, functions

Objects are created from abstract data types that encapsulate ___ and ___ together.

data, functions

When a constructor function accepts no arguments, or does not have to accept arguments because of default arguments, it is called a(n):

default constructor

Assuming that Rectangle is a class name, the statement Rectangle *BoxPtr;

defines a Rectangle pointer variable called BoxPtr

When the body of a member function is defined inside a class declaration, it is said to be

inline

The constructor function's return type is not

int, float, char, or structure pointer (none of these)

Assume that myCar is an instance of the Car class, and that the Car class has a member function named accelerate. Which of the following is a valid call to the accelerate member function?

myCar.accelerate();

The destructor function's return type is:

nothing. Destructors have no return type.

A class may have this many default constructor(s)

only one

If you do not declare an access specification, the default for members of a class is

private

This type of member function may be called only from a function that is a member of the same class.

private

This is used to protect important data.

private access specifier

Examples of access specifiers are the keywords:

private and public

This type of member function may be called from a statement outside the class.

public

If a local variable and a global variable have the same name within the same program, the ___ resolution operator must be used.

scope


Set pelajaran terkait

Sustainable Development Goals (SDGs)

View Set

Gram positive and Gram negative bacteria

View Set

Unit 2 python example quiz that helps he get a 100

View Set

Micro Final (Exercises, Tests and Quizzes)

View Set

2nd half: section 9 Loan Qualification & Financing in. WA

View Set

Chapter 5: Understanding Metrics

View Set

Chapter 16 Therapeutic Relationships intro to OT

View Set

Insurance Property and Casualty test ver

View Set