Classes
Pointers
Arrays
Functions
Miscellaneous
100

What is the keyword used to create a structure?

struct

100

What symbol is used to declare a pointer?

*

100

How do you declare an integer array called 'arr' with 5 elements?

int arr[5];

100

How do you find the sum of 2 and 3 using a function with this prototype?

int sum(int a, int b);

sum(2,3);

100

How do you declare the library that allows you to use cin and cout?

#include <iostream>

200

How do you declare a private member variable for a class?

private:

   int var1;

200

How do you assign the address of variable x to pointer ptr?

ptr = &x;

200

What are the indexes of the elements of an array of length 4?

0, 1, 2, 3

200

How do you return a value in a void function?

You don't, so you can  do 'return;' or leave it blank.

200

What keyword is used to define a constant variable?

const

300

How do you access a public member variable outside a class?

className.var1

300

How do you allocate memory for a single integer using C++'s new operator?

int *ptr = new int;

300

How do you assign the value 10 to the third element in an array?

arr[2] = 10;

300

What is it called when you have two functions that have the same name but differ in how many parameters they have?

Function overloading

300

What keyword is used to exit from a loop early?

break

400

How do you declare a member function inside a class?

void className::func1(int var1) {

// function code

}

400

What C++ keyword is used to deallocate memory allocated by the new operator?

delete

400

How do you access the value of the fourth element of the array using the pointer 'ptr' in C++?

*(ptr + 3)

400

What is the syntax to pass a pointer as an argument to a function in C++?

void functionName(int *ptr) { // function code }

400

How do you add an element to a vector?

vectorName.push_back(element);
500

What does the constructor do and how do you declare it?

It initializes all of a class's member variables when the class is being created. It's declared like this

className::className() {

// constructor code

}

500

How do you access the nth element of an array using a pointer ptr in C++?

*(ptr + n - 1)

500

How do you declare a pointer 'ptr' pointing to the first element of the array 'arr' in C++?

int *ptr = arr; or int *ptr = &arr[0];

500

Declare a function that takes an array as its parameter.

void function1(int arr[], int size) {

// function code

}

500

What file stream would you use if you were trying to print your calculations out into a file?

ofstream

Click to zoom
M
e
n
u