Operator Overloading Comma In C++
In
C++, the operator access to a member of an object -> can be overloaded. If the
operator -> is overloaded, the
call of the class.
Fig:Operator Overloading Comma In C++ |
Program:
#include <iostream>
class Double
{
public:
double d;
Double* operator->()
{
return this; }
};
void main()
{
Double D;
double x;
D.d = 3.85;
x = D->d;
x = D.d;
cout << "x = " << x;
}
Output:
x-3.85
No comments:
Post a Comment