Unlock access to all the studying documents.
View Full Document
Copyright Cengage Learning. Powered by Cognero.
1. A pointer variable is a variable whose content is a memory address.
2. In C++, pointer variables are declared using the reserved word pointer.
3. In the statement
int* p, q;
p and q are pointer variables.
4. The dereferencing operator is also known as the indirection operator and refers to the object to which its operand
points.
Copyright Cengage Learning. Powered by Cognero.
p = new int[50];
dynamically allocates an array of 50 components of type int and p contains the base address of the array.
9. A memory leak is an unused memory space that cannot be allocated.
10. If p is a pointer variable, the statement p = p + 1; is valid in C++.
11. In C++, you declare a pointer variable by using the ____ symbol.
Copyright Cengage Learning. Powered by Cognero.
int x = 33;
int *q;
q = &x;
cout << *q << endl;
16. What is the output of the following code?
int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout << x << “, ” << *p << endl;
17. What is the output of the following code?
int *p;
int x;
x = 12;
p = &x;
cout << x << “, “;
*p = 81;
cout << *p << endl;
Copyright Cengage Learning. Powered by Cognero.
18. Which of the following can be used to initialize a pointer variable?
19. The C++ operator ____ is used to create dynamic variables.
20. The C++ operator ____ is used to destroy dynamic variables.
21. Which of the following operations is allowed on pointer variables?
Copyright Cengage Learning. Powered by Cognero.
26. In a ____ copy, two or more pointers of the same type point to the same memory.
27. In a ____ copy, two or more pointers have their own data.
28. A class ____ automatically executes whenever a class object goes out of scope.
29. Consider the following statement:
Copyright Cengage Learning. Powered by Cognero.
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 ____.
member-wise initialization
30. The ____ constructor is executed when an object is declared and initialized by using the value of another object.
31. Which of the following would be appropriate syntax for the heading of a copy constructor for a class called
rulerType?
rulerType(int inches, int centimeters)
rulerType(const rulerType& myRuler)
copy rulerType(int inches, int centimeters)
32. In C++, virtual functions are declared using the reserved word ____.
Copyright Cengage Learning. Powered by Cognero.
33. In ____ binding, the necessary code to call a specific function is generated by the compiler.
34. Run-time binding is also known as ____ binding.
35. The ____ operator can be used to return the address of a private data member of a class.
36. Consider the following declaration of a struct:
Copyright Cengage Learning. Powered by Cognero.
struct studentType
{
char name[26];
double gpa;
int sID;
char grade;
};
studentType student;
studentType *studentPtr;
The statement (*studentPtr).gpa = 2.5; is equivalent to ___________________ = 2.5;.
37. Consider the following statements:
void pointerParameters(int* &p, double *q)
{
.
.
.
}
In the function pointerParameters, the parameter p is a(n) ____________________ parameter.
38. Consider the following statements:
void pointerParameters(int* &p, double *q)
{
.
.
.
}
In the function pointerParameters, the parameter q is a(n) ____________________ parameter.
Copyright Cengage Learning. Powered by Cognero.
39. The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int
____________________;
40. The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.
41. The binding of virtual functions occurs at program ____________________ time.
42. The ____________________ of a base class automatically makes the destructor of a derived class virtual.