Member Functions Inside the Class

Easy Introduction to C++ Classes & Objects
Solve in Playground →

Problem Statement

Define a `Calculator` class with a public method `int add(int a, int b)` implemented directly inside the class body. The method should return the sum of `a` and `b`. Read two integers, call the method, and print “Sum: [result]”.

Input Format

Two space-separated integers.

Output Format

Print the formatted sum.

Constraints

-1000 <= a, b <= 1000

Sample Input

10 5

Sample Output

Sum: 15

Explanation

Member functions define the behavior of objects and can be implemented directly inside the class definition.

Starter Code

#include <iostream>

class Calculator {
public:
    // Define and implement add() here
};

int main() {
    // Instantiate Calculator, read input, call add, and print
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used