Re: operator overloading
may someone is kind enough to give me indepth knowledge of operator
overloading specially- ,(),comma opeartor,new and delete.
The hard copy of the Eckel book I have has syntax for, AFAIK, *all* the
operators that can be overloaded. The book is free on line, I dislike
E-books so I didn't confirm that all that excruciating detail is in the
E-book The examples are similar to what you posted - no obvious practical
Here is a somewhat more useful example of using the  operator, it gives
you an array that has bounds checking, something lacking in C - but
available if you jump through the right hoops in C++. In a real program it
should "throw" an error instead of printing an error message.. Doing so
here would simply obscure the point of the code.
To use, remove the STOP macros where they appear in the body of the code -
they are there to humor my compiler.
/* 070517 demonstrate overloading of  operator
Create an array of int with 10 elements and detect
out of range errors */
#define STOP while(1) cin.get();
using namespace std;
int& operator (int);
int& Arr::operator (int i)
if(i<0 || i>9)
cout << "Subscript out of range in class Arr\n"
<< "Valid range is 0..9 and value provided was "
<< i << endl;
for(int j=0; j<10; j++)
arr[j] = 100 + j;
for(int k=0; k<10; k++)
cout << arr[k] << endl;
// next two cause error messages
//cout << arr[-1] << endl;
//cout << arr << endl;