Introduction to the this Pointer

Medium Encapsulation, Access Specifiers & The this Pointer
Solve in Playground →

Problem Statement

Create a `Box` class with a method `Box* getAddress()` that simply returns `this`. In `main()`, instantiate a `Box` named `b`, call `getAddress()`, and compare the returned pointer to the memory address of the object (`&b`). Print ‘Match’ if they are equal, otherwise ‘Mismatch’.

Input Format

None

Output Format

Print the exact message.

Constraints

None

Sample Output

Match

Explanation

The `this` pointer is an implicit hidden pointer passed to all non-static member functions, holding the memory address of the calling object.

Starter Code

#include <iostream>

class Box {
public:
    // Implement getAddress() returning this
};

int main() {
    // Instantiate Box, compare pointers, and print result
    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