1. Writing a C++ Program Flashcards

Introduction to variables and classes.

1
Q

True or false?

Every variable in C++ must be associated with a specific type.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or false?

Every function in C++ must return a value

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

According to the C++ standard, what is the name of the function that is the starting point for a program?

A

main()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false?

A class can consist of multiple member data variables of different types, but each type must be specified when the class is defined.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or false?

The member functions of a class always have access to every member data variable of that class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or false?

The member data variables in a class can only be access by the member functions of that class.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which C++ directive is used to insert the contents of another file at the current location while processing the current file?

A

include

The file indicated by the string after the “#include” directive is compiled before the rest of the current file is compiled.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Given the following code:

namespace uiuc {
    class Pair {
        double a,b;
    };
}

How would you create a variable “p” of type Pair outside of the namespace declaration?

A

uiuc::Pair p;

We have to reference the namespace to access the classes defined in it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What keyword is used to indicate which namespace(s) to search to find classes and variables when they are referenced throughout the rest of the program?

A

using

The “using” keyword indicates to the compiler from which namespace references to classes and variables should be found.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the namespace of the C++ Standard Library?

A

std

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which operator is used to send a sequence of strings, numbers, and other values to the standard library’s cout object in a specific order so that they will be printed to the console?

A

«

This is called the “streaming” operator and sends the operand on its right to the stream on its left.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly