Exam 1 Flashcards
Who created c++ and when?
1979: Bjarne Stroustrup began work on “c with classes.” Renamed to c++ in 1983. standardized by ISO in 1998.
What is the difference between g++ and c++?
g++ is the compiler, c++ is the language
true or false: all c programs are valid c++ programs, but not the other way around.
true
true or false: main is a method
false. main is a function
what is a method?
a function inside of a class
what do you need in order to access IO facilities?
include <iostream></iostream>
what do a main function’s return values mean?
0 means success
>0 means failure
<0 means something weird happened
true or false: variable size is standard across implementations
false. size is determined by implementation
what does the const quantifier do?
it makes it so you cannot change a variable
what does the constexpr quantifier do?
it is a compile-time const
what does the static quantifier do?
it means the variable has a longer than function lifetime, but makes it private if it’s a global variable.
true or false: you must initialize variables declared as auto
true
what is cin?
standard input
what is cout?
standard output
what is cerr?
standard error
what operator is used for output with cout?
the insertion operator: «
what does cout «_space;endl do?
it flushes terminal output
what operator is used for input with cin?
the extraction operator:»_space;
how do you read an entire line from a file?
use getline. params are file name & what you will call the line
true or false: you can read a string with»_space;
True. this will read a whitespace delimited string
how do you read a raw char?
use get(). you can also use»_space; to read a whitespace delimited char
what does unget() do?
it will back up by one char
what does peek() do?
it will get and unget a char to peek at it
how do you get the stream state?
test the state by evaluating the string as a bool, since cin»_space; n returns a reference to n