Class Attributes and Accessing Them

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

Problem Statement

Define a `Student` class with a public `std::string name` and `int age`. In `main()`, instantiate the class, read the name and age from standard input, assign them to the object’s attributes, and print “Name: [name], Age: [age]”.

Input Format

A single word string and an integer separated by a space.

Output Format

Print the formatted student information.

Constraints

Name length <= 50

Sample Input

Alice 20

Sample Output

Name: Alice, Age: 20

Explanation

Public attributes hold data specific to an object instance and can be accessed directly using the dot (.) operator.

Starter Code

#include <iostream>
#include <string>

class Student {
    // Define public attributes here
};

int main() {
    // Instantiate Student, read input, assign attributes, 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