Chapter 13 Reviewing the basics

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

True

The address of operator returns the address of its operand. For example, if p is a pointer variable of type int and num is an int variable, the statement: p = # sets the value of p to the address of num.

True

The array name is a constant pointer. It always points to the same memory location, which is the location of the first array component

False

The binding of virtual functions occurs at execution time, not at compile time, and is called compiler binding

True

A class is called an abstract class if it contains one or more pure virtual functions

True

A copy constructor executes when an object is declared and initialized by using the value of another object and when an object is passed by value as a parameter

True

A variable created during program execution is called a dynamic variable

True

Pointer variables contain the addresses of other variables as their values

True

The address of operator can be used to return the address of a private member variable of a class

False

The value of one pointer variable cannot be assigned to another pointer variable of the same type

True

To create a dynamic array, the form of the new operator that creates an array of dynamic variables is used. For example, if p is a pointer of type int, the statement: p = new int[10]; creates an array of 10 components of type int. The base address of the array is stored in p. We call p a dynamic array.

False

When used as a unary operator, * is called the address of operator

False

the operator new is used to deallocate the memory occupied by a dynamic variable

True

A pointer variable is declared using an asterisk, *, between the data type and the variable. For example the statements: int *p; int *ch; declare p and ch to be pointer variables. The value of p points to a memory space of type int, and the value of ch points to a memory space of type char. Usually, p is called a pointer variable of type int, and ch is called a pointer variable of type char

False

An array created during program execution is not called a dynamic array

True

Array notation can be used to access the components of a dynamic array. For example, suppose p is a dynamic array of 10 components. Then, p[0] refers to the first array component, p[1] refers to the second array component, and so on. in particular, p[i] refers to the (i + 1)th component of the array.

True

Because an abstract class is not a complete class--as it (or its implementation file) does not contain the definitions of certain functions--you cannot create objects of that class

False

C++ allows a program to create dynamic just single dimensional arrays

True

C++ allows a user to pass an object of a derived class to a formal parameter of the base class type

False

C++ doesn't allow a user to pass an object of a derived class to a formal parameter of the base class type

False

If a class has a destructor, the destructor does not automatically execute whenever a class object goes out of scope

True

If a class has pointer member variables, the built-in assignment operators provide a shallow copy of the data

True

If p is a dynamic array, then the statement: delete [] p; deallocates the memory occupied by p--that is, the components of p

False

If p is a pointer of type int, the statement: new p; deallocates the memory pointed to by p

True

If p is a pointer of type int, the statement: p = new int; allocates storage of type int somewhere in memory and stores the address of the allocated storage in p

False

In C++, & is called the dereferencing operator

True

In C++, both new and delete are reserved words

True

In C++, no name is associated with the pointer data type

True

In C++, virtual functions are declared using the reserved word virtual

False

In a deep copy, two or more pointers of the same type point to the same memory; that is, they point to the same data

False

In a shallow copy, two or more pointers of the same type have their own copies of the data

True

In addition to the pure virtual functions, an abstract class can contain instance variables, constructors, and functions that are not pure virtual. However, the abstract class must provide the definitions of constructors and functions that are not pure virtual

False

In the statement int **board; the variable board is a pointer, but not a pointer to a pointer

True

Pointer arithmetic is different than ordinary arithmetic. When an integer is added to a pointer, the value added to the value of the pointer variable is the integer times the size of the object to which the pointer is pointing. Similarly, when an integer is subtracted from a pointer, the value subtracted from the value of the pointer variable is the integer times the size of the object to which the pointer is pointing

True

Pointer variables are initialized using either 0 (the integer zero), NULL, or the address of a variable of the same type

False

Pointer variables cannot be compared using relation operators (It doesn't make sense to compare pointers of the same type)

True

The memory location indicated by the value of a pointer variable is accessed using the derferencing operator, *. For example, if p is a pointer variable of type int, the statement: *p = 25; sets the value of the memory location indicated by teh value of p to 25

True

The only arithmetic operations allowed on pointer variables are increment (++) and decrement (--), addition of an integer to a pointer variable, subtraction of an integer from a pointer variable, and subtraction of a pointer from another pointer

False

The only number that can be directly assigned to a pointer variable is 1

True

The operator delete has two forms: one to deallocate the memory occupied by a single dynamic variable and another to deallocate the memory occupied by an array of dynamic variables

False

The operator delete is used to create a dynamic variable

True

The operator new has two forms: one to create a single dynamic variable and another to create an array of dynamic variables

False

You cannot use the member access operator arrow, ->, to access the component of an object pointed to by a pointer


Ensembles d'études connexes

HR MANAGEMENT/MULTIPLE CHOIE & T/F

View Set

Exam 2 study Questions (CH's 9,11,12)

View Set

Comptia A+ Chapter 6 - Networking Fundamentals

View Set

Chapter 26 Health Assessment The point

View Set

Genetics Unit 2 Chapters 6 and 7

View Set