1 Classes & objects
A class bundles data and behaviour. Objects are instances. Access control (public/private) enforces encapsulation.
class Point {
public:
int x, y;
int sum() { return x + y; }
};
Point p{3, 4};
// p.sum() == 7Classes & objects, the STL containers, and references.
A class bundles data and behaviour. Objects are instances. Access control (public/private) enforces encapsulation.
class Point {
public:
int x, y;
int sum() { return x + y; }
};
Point p{3, 4};
// p.sum() == 7The Standard Template Library offers vector, map, set and algorithms like sort — reusable and efficient.
#include <vector>
std::vector<int> v{3, 1, 2};
std::sort(v.begin(), v.end()); // 1 2 3A reference (int&) is an alias — pass large objects by const reference to avoid costly copies. (The runnable example sums even numbers.)
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for (int i = 2; i <= 20; i += 2) sum += i;
cout << "sum of evens = " << sum << endl;
return 0;
}
Code runs on a learning-oriented simulated runtime that supports common constructs (output, variables, arithmetic, conditionals and loops).
5 tasks across 2 pages — multiple-choice and fill-in (type the answer). Score 70% or higher to earn your certificate.
🔒 Pass the quiz above (70%+) to unlock your downloadable certificate.
Congratulations! Enter your name to generate your certificate.