May 1996
Intermediate to advanced
304 pages
5h 54m
English
Imagine we have the apparently simple expression
if ( yy == xx.getValue() ) ...
where xx and yy are defined as
X xx; Y yy;
class Y is defined as
class Y {
public:
Y();
~Y();
operator==( const Y& ) const;
// ...
}; and class X is defined as
class X {
public:
X();
~X();
operator Y() const;
X getValue();
// ...
}; Simple stuff, right? Okay, let’s look at how the expression is handled.
First, we determine the actual instance of the equality operator that is being referenced. In this case, this resolves to the overloaded Y member instance. This is the first transformation of our expression:
// resolution of intended operator if ( yy.operator==( xx.getValue() ))
Y’s equality operator requires an argument of type Y. getValue() ...
Read now
Unlock full access