1. Writing a C++ Program Flashcards
Introduction to variables and classes.
True or false?
Every variable in C++ must be associated with a specific type.
True
True or false?
Every function in C++ must return a value
False
According to the C++ standard, what is the name of the function that is the starting point for a program?
main()
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.
True
True or false?
The member functions of a class always have access to every member data variable of that class.
True
True or false?
The member data variables in a class can only be access by the member functions of that class.
False
Which C++ directive is used to insert the contents of another file at the current location while processing the current file?
include
The file indicated by the string after the “#include” directive is compiled before the rest of the current file is compiled.
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?
uiuc::Pair p;
We have to reference the namespace to access the classes defined in it.
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?
using
The “using” keyword indicates to the compiler from which namespace references to classes and variables should be found.
What is the namespace of the C++ Standard Library?
std
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?
«
This is called the “streaming” operator and sends the operand on its right to the stream on its left.