This module is designed to deepen understanding of C++ type conversion, serialization, and polymorphism through practical exercises.
- Goal: Implement a
ScalarConverterclass 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.
- Handle pseudo-literals (
- Goal: Implement a
Serializerclass 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-empty
Datastructure to test serialization.
- Goal: Create a base class and derive three classes (
A,B,C) with type identification functionality. - Key Features:
- Implement
Base* generate(void)to randomly instantiate and return one of the derived types. - Use
void identify(Base* p)andvoid identify(Base& p)to detect the actual type. - Avoid using
std::typeinfo.
- Implement
- Language: C++98
- Compilation:
- A
Makefileis provided for compilation. - Include the necessary headers for numeric limits and special values handling.
- A
- Environment: Linux-based systems or any compatible environment supporting C++98.
- Clone the repository:
git clone <repository-url> cd <repository-folder>
- Build the project:
make
- Run the individual exercices:
./convert <literal> ./serialize ./identify
- Clean up:
make fclean
