Basic C++
Class by Reference
121 Stuff
Class Teminology
100

The name of the thing on the left of a function's name

Data Type or Return Type

100

Is this pass by reference?

int multBothByTwo(int& var1, int& var2){         

    var1 *= 2;
    var2 *= 2;
    return var1 + var2; 

}

Yes

100

What is the name of the Operating System most people tell you to use in CS?

Linux

100

What's another way to refer to an object?


An object is a specific instance of a class.

200

what kind of loop runs until ONE conditional is no longer met?

while loop or do-while loop

200

True or False and why:

public member variable can ONLY be accessed by the class itself

False, that's for private member variables

200

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.

200

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.

300

name 3 objects you need to have std:: in front of

string, vector, map, cout, cin....

300

What is the name of the keyword that tells C++ that you are making a class?

class

300

What is the file extension that tells you that it is an IMPLEMENTATION file?

.cc and/or .cpp

300

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>};

400

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 <  >

400

When is it appropriate to define an input to have const AND &

When the input should be immutable and pass by ref

400

What is the proper order of the following:

git commit 

git add

git push

add, commit, push

400

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

500

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

500

When should you put const after the () in a function definition?

When you don't want to modify the class you're working in

500

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)

500

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;
}


M
e
n
u