Member Functions Outside the Class (:: Scope Resolution)

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

Problem Statement

Define a `Greeter` class with a public method declaration `void sayHello();`. Implement this method *outside* the class using the scope resolution operator (`::`). The method should print “Hello from outside”. Instantiate the class and call the method.

Input Format

None

Output Format

Print the exact greeting.

Constraints

None

Sample Output

Hello from outside

Explanation

Separating declaration from implementation keeps class definitions clean and readable, using `ClassName::MethodName` to link them.

Starter Code

#include <iostream>

class Greeter {
public:
    // Declare sayHello() here
};

// Implement sayHello() outside the class using ::

int main() {
    // Instantiate Greeter and call sayHello()
    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