The name of the thing on the left of a function's name
Data Type or Return Type
Is this pass by reference?
int multBothByTwo(int& var1, int& var2){
var1 *= 2;
var2 *= 2;
return var1 + var2;
}
Yes
What is the name of the Operating System most people tell you to use in CS?
Linux
What's another way to refer to an object?
An object is a specific instance of a class.
what kind of loop runs until ONE conditional is no longer met?
while loop or do-while loop
True or False and why:
public member variable can ONLY be accessed by the class itself
False, that's for private member variables
What does a class let us do? What is it similar to in real life?
A class lets you define your own data type. It is similar to a blueprint that lets us create objects or "instances" of the class.
What are our 2 main access specifiers?
public and private. We also have a protected access specifier, but don't worry about that for now. We'll get to that when we cover inheritance.
name 3 objects you need to have std:: in front of
string, vector, map, cout, cin....
What is the name of the keyword that tells C++ that you are making a class?
class
What is the file extension that tells you that it is an IMPLEMENTATION file?
.cc and/or .cpp
What is the difference between declaring vs. initializing a variable? If there's a pattern what is the pattern for each?
Declaring only includes the data type and variable name.
Ex: <type> <identifier> = <value>;
Initializing includes declaring the variable and assigning it some value.
Ex. <type> <identifier> = <value>; // or
Ex. <type> <identifier>{<value>};
Is this correct C++ syntax? If not why?
int main(){
std::vector my_vector;
my_vector.push_back("hey there");
}
no, std::vector needs a data type in < >
When is it appropriate to define an input to have const AND &
When the input should be immutable and pass by ref
What is the proper order of the following:
git commit
git add
git push
add, commit, push
What is overloading? Where have we seen overloading so far?
Overloading is the concept of defining multiple functions with the same name in the same scope. We've seen overloading in constructors
Is this proper C++ syntax?
int main(){
std::vector<std::string> my_vector;
my_vector.push_back("hey there");
std::map<int, int> mapping{};
std::cout << mapping << std::endl;
my_vector.push_back("");
my_vector.pop_back();
}
no, you can't cout a map
When should you put const after the () in a function definition?
When you don't want to modify the class you're working in
What makes up a function prototype? Give an example of what a function prototype looks like.
return type, function name, and parameter list
Ex: int someFunction(int param1, int param2)
What is the difference between a function declaration vs. a function definition? Give an example of both.
A function declaration includes the prototype and a semicolon whereas a function definition includes the prototype and function body.
Declaration Ex:
int someFunction(int param1, int param2);
Definition Ex:
int someFunction (int param1, int param2) {
return param1 * 2 / param2;
}