Final 1 Programming

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

To use the strlen function in a program you must include

#include<cstring>

What will the following code display? int numbers[] = {99, 87, 66, 55, 101}; cout << numbers[3] << endl;

55

Class objects can be defined prior to the class declaration

False

The setprecision manipulator cannot be used to format data written to a file.

False

To write to a file, you use the file_write function.

False

When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private members.

False

You may overload any C++ operator and you may use the operator function to define non-standard operations, such as @ or ^.

False

To use any of the smart pointers in C++11 you must use the following directive in the header file: #include <memory>

True

When passing a file stream object to a function, you should always pass it by reference.

True

The function that accepts a C-string containing a number as its argument and returns the integer equivalent is

atoi

After the code shown executes, which of the following statements is TRUE? int numbers[] = {0, 1, 2, 3, 4}; int *ptr = numbers; ptr++;

ptr will hold the address of numbers[1]

To help prevent memory leaks from occurring in C++11, a ________ automatically deletes a chunk of dynamically allocated memory when the memory is no longer being used.

smart pointer

What will the following code display? int numbers{4} = {99, 87}; cout << numbers[3] << endl;

0

Which type of function is NOT a member of a class but has access to the private members of the class?

Friend

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!

A member function that is declared ________ may not access any non-static data members in the class.

Static

Objects in an array are accessed with ________.

Subscripts

By default, when an object is assigned to another object, each member of one object is copied to its counterpart in the other object.

True

C++ does not perform array bounds checking, making it possible for you to assign a pointer the address of an element out of the boundaries of an array.

True

Destructor functions are often used to free memory that was allocated by the object.

True

If a file already exists, you can open it with the flags ios::in | ios::out to preserve its contents.

True

It is possible for a structure variable to be a member of another structure variable.

True

More than one constructor function may be defined for a class.

True

The overloaded = operator copies data from one object to another so it is known as the overload copy operator.

True

You can use the technique known as a member initialization list to initialize members of a class.

True

Given the following structure declaration, idNum is struct Employee { string name; int idNum; };

a member

Which of the following can be used as pointers?

array names

A structure ________ contain members of the same data type.

can

It is a good idea to make a copy constructor's parameters ________ by specifying the ________ key word in the parameter list.

constant, const

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

constructor, created

Which of the following data types can be used to create files and read information from them into memory?

ifstream

This following statement shows an example of ________. int grades][ ] = {100, 90, 99, 80};

implicit array sizing

To pass an array as an argument to a function, pass the ________ of the array.

name

If a is a structure variable and p, a pointer, is a member of the structure, what will the following statement do? cout << *a.p;

output the dereferenced value pointed to by p

Which of the following is the member function that writes a single character to a file?

put

The ________ function concatenates the contents of one C-string with another C-string.

strcat

The function that accepts pointers to two C-strings and an integer argument that indicates how many characters to copy from the second string to the first is

strncpy

The arguments of the strcpy function are

two addresses

Which statement correctly uses C++11 to initialize a vector of ints named n with the values 10 and 20?

vector<int> n {10, 20};

The following statement ________. bookList[2].publisher[3] = 't';

will store the character 't' in the fourth element of the publisher member of bookList[2]


Set pelajaran terkait

Examen Oral - Answer in complete sentences

View Set

Decision Point - Session 3 Vocabulary: The Jesus Question

View Set

A&P 2-Fluid, Electrolyte, and Acid-Base Balance

View Set

Chapter 8: Standard Costs and Variances

View Set