 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
Notice
that this conversion function has no return type.
|
|
|
That
is because the return type is implicitly specified
|
|
|
(other_type),
since that is the type we are converting to.
|
|
|
| • |
The
conversion function converts the current object into
|
|
the
new type and returns the value.
|
|
|
| • |
The
name of the conversion function must be a single
|
|
|
identifier;
therefore, for types that are not a single
|
|
|
identifier,
a typedef must first be used. In the class:
|
|
typedef const char* pchar; //make
single identifier
|
|
operator pchar(); //conversion (name to char*)
|
|
|
Implementing:
|
|
name::operator pchar() { //conversion function
|
|
...
|
|
return array; //of type char * being returned
|
|
}
|
|