,
.
,
. :
ff(
ZooAnimal& );
ff( Screen& );// ff( ZooAnimal& )ff( yinYang
);*
void
*.ff( Screen& );
ff( void* );// ff( void* ) ff( yinYang
);
,
. ,
:
ff( Bear& );ff( Panda&
);
ZooAnimal za;ff( za ); // error : no match
. , Panda Bear Endangered.
Panda .
, .
ff( Bear& );ff(
Endangered& );
ff( yinYang ); // error : ambiguous
, :
ff(
Bear(yinYang));
-
- .
,
. Panda - Bear,
ZooAnimal .
ff( ZooAnimal&
); ff( Bear& );// ff( Bear& ); ff( yinYang );
void*. ,
:
ff( void* );ff( ZooAnimal* );
Panda*
ZooAnimal*.
.
.
ZooAnimal
:
class ZooAnimal
{public:
ZooAnimal( long );//
conversion : long ==> ZooAnimal
operator char*();// conversion : ZooAnimal
==> char*
// ...
};
:
ff( ZooAnimal& );
ff( Screen& );
long ZooAnimal
:
long lval;//
ff( ZooAnimal& )
ff( lval );
,
int? ,
ff( 1024 ); // ???
, .
.
, ZooAnimal
long, int.
. , 1024 long,
ZooAnimal.
ZooAnimal.
. ff()
,
ZooAnimal . ,
ff( ZooAnimal& );
ff(
char );// ff( char );
long lval;
ff( lval );
ZooAnimal:
ff( ZooAnimal(lval));// ff( ZooAnimal& )
char* ZooAnimal
.
ff( char* );
ff( Bear& );
ZooAnimal za;// za ==> char*
// ff( char* ) ff( za );
, . ,
ff(
Panda* );
ff( void* );
// za ==> char* ==> void
// ff( void*
)
ff( za );
( )
. Bear, Panda
char* ZooAnimal. ,
ff(
char* );
ff( Bear* );
Bear yogi;
Bear pBear = &yogi;// ff( char
)ff( yogi );// ff( pBear ) ff( pBear );
,
.
. ,
. , Endangered
int:
class Endangered {
public:
operator int();// conversion :
Endangered ==> int
// ...};
Extinct
,
Endangered,
class Extinct {
public:
Extinct(
Endangered& );
// ...
};
.
Endangered
Extinct .
ff( Extinct& );
ff( int
);
Endangered e;
ff( e ); // error : ambiguous
.
SmallInt BitVector
- .
class SmallInt
{
public:
SmallInt( int );// conversion : int ==> SmallInt
//
...
};
class BitVector {
BitVector( unsigned long );// conversion :
unsigned long ==> BitVector
// ...};
ff( SmallInt& );
ff(
BitVector& );
ff( 1 ); // error : ambiguous