Classes
Pointers
STD Library
Functions
Misc.
100

When I declare variables inside a class without specifying an access modifier, are they private or public by default?

Private

100

This keyword lets us dynamically allocate memory in C++.

the "new" keyword

100

We include this header file so we can perform input and output to the console.

what is #include<iostream> or just <iostream>

100

You include this key word when your function does NOT return a value

What is "void"

100

When you declare a struct in C++, are the member variables public or private by default?

What is public

200

What special method is automatically called when an object of a class is created?

A constructor

200

This error occurs when you forget to use the delete keyword after dynamically allocating memory with new.

A memory leak
200

I have a user defined header file called "Foo.h", how would I include it into my main.cpp file?

What is #include "Foo.h"

200

How would you write a void function that doubles the value of a given integer variable?

void myFunc(int &x) {
    x *= 2;
}


200

This algorithm allows us to search through a sorted array very quickly by repeatedly dividing the search interval in half.

What is binary search

300

Whenever we use pointers or dynamically allocated memory in a class, we must define this special method to properly clean up after the object is destroyed.
(Hint: its symbol is ~)

A destructor

300

What does this following program print

int x = 10;
int* y = &x;
int z = *y;
scout << "This program prints: " << z << endl;


This program prints: 10

300

Which header file should I include if I want arrays that can grow and shrink in size at runtime?

what is #include<vector>
300

This following function demonstrates what method? 

int factorial(int n) {
    if (n <= 1) return 1;
    return n * factorial(n - 1);
}

What is recursion?

300

Declaring a member function with this keyword after the parentheses promises not to modify the object.

What is const

400

Given this declaration of a class
class Foo {
  int x;  

  double y;
  string z;
};

Create a constructor using the following type declaration (assume namespace std)

Foo(num1, num2, word);

Foo(int num1, double num2, string word) {
    x = num1;
    y = num2;
    z = word;
}


400

(DAILY DOUBLE)When we dynamically allocate an object of a class, this operator allows us to access its methods directly.

 What is the '->' operator (arrow)

400

Given the following declaration
vector<int> arr = {1, 2, 3};

How would you add another entry with the value 4 to this vector?

What is arr.push_back(4); ?

400

What process is being done in the following code snippet?

Vector2D operator+(const Vector2D &other) {
    return Vector2D(x + other.x, y + other.y);
}


What is operator overload?

400

This sorting algorithm repeatedly checks if the number after an index is smaller, and swaps positions if it is, moving larger numbers to the end of the array.

What is bubble sort.

500

Given this class

class Animal {
public:
    void speak() { cout << "Animal sound\n"; }
};

Finish this class header so that Dog inherits Animal
class Dog {
   
};


class Dog : public Animal {};


500

(DAILY DOUBLE)What does the following program print?
float x = 5;
float y = &x;
cout << y << endl;


This code will compile as an error (the declaration for float y is wrong since it's missing "float* y")

500

Fix the following program so it compiles correctly: 

#include <iostream>
int main() {
    int x = 0;
    int y = 2;
    cout << "num 1 is " << x << " num 2 is " << y << endl;
}


std::cout << "num 1 is " << x << " num 2 is " << y << std::endl;


500

In the following code snippet, what does typename T represent? 

template <typename T>
T add(T a, T b) {
    return a + b;
}


It allows ANY datatype to work with the function.

500

This directive ensures that a header file is included only once in a compilation, preventing multiple definition errors.

What is #pragma once