Welcome to Int-as-integer-data_type! This project provides a robust, custom Int class wrapper for C++ that enhances the standard integer type with additional object-oriented features, safety mechanisms, and utility functions.
Whether you're looking to simplify pointer management or just want a more flexible integer type for your next project, this library has you covered.
- Seamless Arithmetic: Fully supports
+,-,*,/, and%operations, working just like native integers. - Full Comparison Suite: Includes all comparison operators (
==,!=,<,>,<=,>=) for easy logic flow. - Stream Integration: Built-in support for
std::cinandstd::cout, making I/O operations intuitive and clean. - Smart Pointer Deletion: Comes with a unique
ptr_deleterutility to safely handle and delete multipleIntpointers recursively—no more memory leaks! - Compound Assignments: Supports
+=,-=,*=,/=, and%=for concise code.
Integrating Int into your project is as simple as dropping the files in!
- Copy
Int.handInt.cppinto your project directory. - Include the header file in your code:
#include "Int.h"
Compile your project using your favorite C++ compiler. For example, using g++:
g++ main.cpp Int.cpp -o my_programHere are a few ways you can use the Int class to make your C++ coding easier.
#include <iostream>
#include "Int.h"
int main() {
Int a(10);
Int b(5);
Int sum = a + b;
Int product = a * b;
std::cout << "Sum: " << sum << std::endl; // Output: 15
std::cout << "Product: " << product << std::endl; // Output: 50
return 0;
}Forget about manually deleting every single pointer. Use ptr_deleter to clean up multiple objects in one go!
Int* p1 = new Int(100);
Int* p2 = new Int(200);
Int* p3 = new Int(300);
// Do some work...
// Clean up all pointers nicely
ptr_deleter(p1, p2, p3);Contributions, issues, and feature requests are welcome! Feel free to check the specific files to understand how implementations work and suggest improvements.
This project is open resource. See the LICENSE file for more details.