Constructor Overloading

Medium Object Lifecycle (Constructors & Destructors)
Solve in Playground →

Problem Statement

Create a `Point` class. Implement a default constructor that prints ‘Origin’ and a parameterized constructor (taking x and y) that prints ‘Point(x, y)’. Read an integer N. If N is 0, use the default constructor. If N is 1, read two more integers (x and y) and use the parameterized constructor.

Input Format

An integer N, optionally followed by two integers if N is 1.

Output Format

Print the respective constructor output.

Constraints

N is 0 or 1.

Sample Input

1 4 5

Sample Output

Point(4, 5)

Explanation

Constructor overloading allows multiple ways to instantiate an object depending on the arguments provided.

Starter Code

#include <iostream>

class Point {
public:
    // Implement default and parameterized constructors
};

int main() {
    int n;
    if (std::cin >> n) {
        // Write logic to instantiate Point based on n
    }
    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