Some of the special operators in C++ are: new – used to allocate memory dynamically delete – used to free memory dynamically ( ) and – subscript operators -> – member access operator Let’s see how to overload them. Overloading new and delete operators C++ allows programmers to overload new and delete operators due to following reasons: To add more functionality when allocating or deallocating memory. To allow users to debug the program and keep track of memory allocation and deallocation in their programs. Syntax for overloading new operator is as follows: void* operator new(size_t size); Parameter size specifies the size of memory
The post How to overload special Operators in c++ appeared first on Coding Security.
How to overload special Operators in c++
read more
Tidak ada komentar:
Posting Komentar