{"id":27154973,"url":"https://github.com/maximilianfeldthusen/simpleusermanagementsystem","last_synced_at":"2026-03-07T09:31:10.990Z","repository":{"id":283195790,"uuid":"950992705","full_name":"maximilianfeldthusen/SimpleUserManagementSystem","owner":"maximilianfeldthusen","description":"The code implements a simple user management system using classes, exception handling, and smart pointers for memory management.","archived":false,"fork":false,"pushed_at":"2025-04-24T16:37:45.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"TFD","last_synced_at":"2025-10-05T19:36:48.963Z","etag":null,"topics":["classes","cpp","exception-handling","user-management"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximilianfeldthusen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-19T02:05:03.000Z","updated_at":"2025-04-24T16:37:50.000Z","dependencies_parsed_at":"2025-03-19T03:22:17.536Z","dependency_job_id":"fb1946b4-7bea-4eee-b27e-6260fb30c635","html_url":"https://github.com/maximilianfeldthusen/SimpleUserManagementSystem","commit_stats":null,"previous_names":["maximilianfeldthusen/simpleusermanagementsystem"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maximilianfeldthusen/SimpleUserManagementSystem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2FSimpleUserManagementSystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2FSimpleUserManagementSystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2FSimpleUserManagementSystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2FSimpleUserManagementSystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximilianfeldthusen","download_url":"https://codeload.github.com/maximilianfeldthusen/SimpleUserManagementSystem/tar.gz/refs/heads/TFD","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2FSimpleUserManagementSystem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30210829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classes","cpp","exception-handling","user-management"],"created_at":"2025-04-08T18:56:40.826Z","updated_at":"2026-03-07T09:31:10.769Z","avatar_url":"https://github.com/maximilianfeldthusen.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Documentation\n\n### SimpleUserManagementSystem\n\nThis C++ code implements a simple user management system using classes, exception handling, and smart pointers for memory management. Let's break down the code step-by-step:\n\n### 1. Includes and Namespace\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cvector\u003e\n#include \u003cmemory\u003e\n#include \u003cstdexcept\u003e\n```\nThese include directives allow the program to use various standard library features:\n- `\u003ciostream\u003e` for input and output (using `std::cout` and `std::cerr`).\n- `\u003cstring\u003e` for using the `std::string` class.\n- `\u003cvector\u003e` for using the `std::vector` container.\n- `\u003cmemory\u003e` for smart pointers (specifically `std::unique_ptr`).\n- `\u003cstdexcept\u003e` for standard exception classes like `std::invalid_argument`.\n\n### 2. User Class\n```cpp\nclass User {\npublic:\n    User(const std::string\u0026 name, int age) : name(name), age(age) {\n        if (age \u003c 0) {\n            throw std::invalid_argument(\"Age cannot be negative\");\n        }\n    }\n\n    void display() const {\n        std::cout \u003c\u003c \"User: \" \u003c\u003c name \u003c\u003c \", Age: \" \u003c\u003c age \u003c\u003c std::endl;\n    }\n\nprivate:\n    std::string name;\n    int age;\n};\n```\n- **Constructor**: Takes a `name` and `age` as parameters. If the `age` is negative, it throws an `std::invalid_argument` exception.\n- **display()**: A member function that prints out the user's name and age.\n- **Private Members**: `name` and `age` are private, ensuring they can only be accessed through the class's public methods.\n\n### 3. UserManager Class\n```cpp\nclass UserManager {\npublic:\n    void addUser(const std::string\u0026 name, int age) {\n        // Validate input\n        if (name.empty() || name.length() \u003e 50) {\n            throw std::invalid_argument(\"Name must be between 1 and 50 characters\");\n        }\n        users.emplace_back(std::make_unique\u003cUser\u003e(name, age));\n    }\n\n    void displayUsers() const {\n        for (const auto\u0026 user : users) {\n            user-\u003edisplay();\n        }\n    }\n\nprivate:\n    std::vector\u003cstd::unique_ptr\u003cUser\u003e\u003e users; // Use smart pointers for memory management\n};\n```\n- **addUser()**: This method takes a `name` and `age` and validates them. If the name is empty or longer than 50 characters, it throws an exception. If the input is valid, it creates a new `User` object using `std::make_unique` (which returns a `std::unique_ptr` to handle dynamic memory safely) and adds it to the `users` vector.\n- **displayUsers()**: This method iterates through the `users` vector and calls the `display()` method of each `User` object to output their information.\n- **Private Member**: `users` is a vector of `std::unique_ptr\u003cUser\u003e`, ensuring that the memory for `User` objects is managed automatically (no need to manually delete them).\n\n### 4. Main Function\n```cpp\nint main() {\n    UserManager userManager;\n\n    // Try to add users\n    try {\n        userManager.addUser(\"Alice\", 30);\n        userManager.addUser(\"Bob\", 25);\n    } catch (const std::exception\u0026 e) {\n        std::cerr \u003c\u003c \"Error adding user: \" \u003c\u003c e.what() \u003c\u003c std::endl;\n    }\n\n    // Attempt to add a user with invalid age\n    try {\n        userManager.addUser(\"Charlie\", -5); // This will throw an exception\n    } catch (const std::exception\u0026 e) {\n        std::cerr \u003c\u003c \"Error adding user: \" \u003c\u003c e.what() \u003c\u003c std::endl; // Handle exceptions\n    }\n\n    // Display users\n    userManager.displayUsers();\n\n    return 0;\n}\n```\n- **Creating UserManager**: An instance of `UserManager` is created.\n- **Adding Users**: The program tries to add two users, \"Alice\" and \"Bob\". If any exceptions occur during this process, they are caught, and an error message is printed to the standard error stream.\n- **Invalid User Attempt**: The program attempts to add a user \"Charlie\" with a negative age, which will cause an exception to be thrown and caught, with an error message printed.\n- **Displaying Users**: Finally, the program calls `displayUsers()` to print the details of all valid users that were added.\n\n### Summary\nThe code demonstrates:\n- Class design and encapsulation by organizing user-related functionality into `User` and `UserManager` classes.\n- Exception handling to manage invalid inputs gracefully.\n- Usage of smart pointers for automatic memory management, preventing memory leaks.\n- Basic input validation to ensure data integrity. \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianfeldthusen%2Fsimpleusermanagementsystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximilianfeldthusen%2Fsimpleusermanagementsystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianfeldthusen%2Fsimpleusermanagementsystem/lists"}