Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Develop a series of C++ utilities for type conversion, serialization, and runtime type identification. Implement ScalarConverter for literal conversion, Serializer for pointer serialization, and a Base hierarchy with dynamic type identification using polymorphism.

NotificationsYou must be signed in to change notification settings

cypri1-dev/42_CPP06

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

Overview

This module is designed to deepen understanding of C++ type conversion, serialization, and polymorphism through practical exercises.

Projects

Exercise 00: Conversion of Scalar Types

  • Goal: Implement aScalarConverter class with a single static method,convert, to convert a string literal into multiple scalar types (char,int,float,double).
  • Key Features:
    • Handle pseudo-literals (nan,+inf,-inf, etc.).
    • Manage non-displayable and impossible conversions with clear error messages.
    • The class should not be instantiable.

Exercise 01: Serialization

  • Goal: Implement aSerializer class with the following methods:
    • uintptr_t serialize(Data* ptr);
    • Data* deserialize(uintptr_t raw);
  • Key Features:
    • Convert a pointer to an unsigned integer type and back.
    • Ensure the deserialized pointer matches the original.
    • Create a non-emptyData structure to test serialization.

Exercise 02: Identify Real Type

  • Goal: Create a base class and derive three classes (A,B,C) with type identification functionality.
  • Key Features:
    • ImplementBase* generate(void) to randomly instantiate and return one of the derived types.
    • Usevoid identify(Base* p) andvoid identify(Base& p) to detect the actual type.
    • Avoid usingstd::typeinfo.

Requirements

  • Language: C++98
  • Compilation:
    • AMakefile is provided for compilation.
    • Include the necessary headers for numeric limits and special values handling.
  • Environment: Linux-based systems or any compatible environment supporting C++98.

Usage

  1. Clone the repository:
    git clone<repository-url>cd<repository-folder>
  2. Build the project:
    make
  3. Run the individual exercices:
    ./convert<literal>./serialize./identify
  4. Clean up:
    make fclean

About

Develop a series of C++ utilities for type conversion, serialization, and runtime type identification. Implement ScalarConverter for literal conversion, Serializer for pointer serialization, and a Base hierarchy with dynamic type identification using polymorphism.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp