Programming Fundamentals 2 Quiz 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is an assignment operator

An assignment operator copies information from one object to another in a deep format where they have the same information but not the same addresses

What is the purpose of template <typename T> in a class declaration

Establishes that the class is gonna be a template and what variable is going to be used

What is a memory leak

A memory leak is when access to memory on the heap or free store has been lost and cannot be accessed

What is a copy constructor

A copy constructor is the constructor which take same class object reference as the parameter. It gets automatically invoked as soon as the object is initialized with another object of the same class at the time of its creation.

How to protect a class from modifying this

Add const after the method parameters

How to create a const variable

Add const before the variable type

Breakpoints

Can choose a spot in the program to stop the program from running and see what is going on in its memory. Done by clicking on the side of a line of code or clicking F9 on the line you're on in Visual Studio

What does the delete key word do

De-allocates a block of memory from the heap of free store

Step over

Is going to go to the next line of code in the current function

Where does "new" memory get allocated

New memory gets allocated in the free store or the heap

Step out

Step out of the current function into what called it

Step Into

Steps into the current function on that line of code if there is one

What is the purpose of a template

Templates are used when the data being inputted is not going to be of the same data type so it has to be dealt with in a general way

What are the Big Three

The big three states that when creating either an assignment operator, copy constructor, then the other two need to be used aswell.

What does the new keyword do

The new keyword allocates dynamic memory to the heap or free store

What is the rule of three

The rule of three states that when creating either an assignment operator, copy constructor, then the other two need to be used aswell.

What is the purpose of using brackets with new and delete

Using brackets shows it is dynamic memory that is going to be allocated or deallocated from the heap or free store

Where do variables in functions get declared

Variables in functions get declared in the stack

What is the stack overflow error and how can it happen

When a program uses more memory than the stack has available

How to view variables locally

You can view variables locally by opening up the autos window when debugging by doing Ctrl+Alt+V A

What is a constant pointer

const int* ptr; declares ptr a pointer to const int type. You can modify ptr itself but the object pointed to by ptr shall not be modified. int * const ptr; declares ptr a const pointer to int type. You are not allowed to modify ptr but the object pointed to by ptr.

What is a destructor

fFnction (much like constructor) which is called when the object is explicitly deleted by code, or when the object passes out of scope, which can happen when the program exits a function; has the same name as the class, but with a tilde prefix.


Conjuntos de estudio relacionados

Chapter 02 Competitiveness, Strategy, and Productivity

View Set

Wonderlic - Assessment Test #1, Assessment Test #2, Assessment Test #3, Assessment Test #4, Assessment Test #5, Assessment Test #6, Assessment Test #7

View Set

Psychology questions - Capparelli, Mezo

View Set

HCS-D Certification Practice Questions

View Set