Object Serialization

Medium Design Patterns & Final Challenges
Solve in Playground →

Problem Statement

Create a `User` class with an integer `id` and string `name`. Create a method `std::string serialize()` that converts the object state into a comma-separated string `”id,name”`. Read an integer and string, instantiate `User`, serialize it, and print ‘Serialized: [str]’.

Input Format

An integer followed by a string.

Output Format

Print the serialized string.

Constraints

None

Sample Input

101 Alice

Sample Output

Serialized: 101,Alice

Explanation

Serialization transforms a live memory object into a transportable or storable format, like strings or byte arrays.

Starter Code

#include <iostream>
#include <string>
#include <sstream>

class User {
public:
    // Implement state and serialize()
};

int main() {
    // Build User, serialize, 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