C++ Chapter 12 – Flashcards
Unlock all answers in this set
Unlock answersquestion
If p is a pointer variable, the statement p = p + 1; is valid in C++.
answer
True
question
What is the output of the following code?
int *p;
int x;
x = 12;
p = &x;
cout << x << ", ";
*p = 81;
cout << *p << endl;
answer
12, 81
question
The ____ constructor is executed when an object is declared and initialized by using the value of another object.
answer
copy
question
In C++, virtual functions are declared using the reserved word ____.
answer
virtual
question
Which of the following operations is allowed on pointer variables?
answer
==
question
What is the output of the following statements?
int x = 33;
int *q;
q = &x;
cout << *q << endl;
answer
33
question
In C++, the dot operator has a lower precedence than the dereferencing operator.
answer
False
question
Given the declaration int *a;, the statement a = new int[50]; dynamically allocates an array of 50 components of the type ____.
answer
int
question
What is the value of x after the following statements execute?
int x = 25;
int *p;
p = &x;
*p = 46;
answer
46
question
An array created during the execution of a program is called a(n) ____ array.
answer
dynamic
question
The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.
answer
True
question
Given the declaration
int *p;
The statement
p = new int[50];
dynamically allocates an array of 50 components of type int and p contains the base address of the array.
answer
True
question
A pointer variable is a variable whose content is a memory address
answer
True
question
In a ____ copy, two or more pointers of the same type point to the same memory.
answer
shallow
question
What is the output of the following code?
int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout << x << ", " << *p << endl;
answer
43, 43
question
In the statement
int* p, q;
p and q are pointer variables.
answer
False
question
The ____ operator can be used to return the address of a private data member of a class.
answer
address of
question
In C++, ____ is called the address of operator.
answer
&
question
Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType?
answer
rulerType(const rulerType& myRuler)
question
Variables that are created during program execution are called static variables.
answer
False
question
In C++, the member access operator arrow is >>.
answer
False
question
The code int *p; declares p to be a(n) ____ variable.
answer
pointer
question
In a ____ copy, two or more pointers have their own data.
answer
deep
question
In C++, pointer variables are declared using the reserved word pointer.
answer
False
question
Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).
answer
eight
question
Which of the following can be used to initialize a pointer variable?
answer
nullptr
question
ptrMemberVarType objectThree(objectOne);
The values of the member variables of objectOne are being copied into the corresponding member variables of objectThree. This initialization is called the ____.
answer
member-wise initialization