November 1999
Intermediate to advanced
336 pages
6h 29m
English
The previous example is a special case of the more general type mismatch. We tried to initialize an object of type Rational with an integer. The generic case of type mismatch is any time an object of type X is expected and some other type is provided. The compiler needs, somehow, to convert the provided type into the expected object of type X. A temporary may get generated in the process. Look at the following:
{
Rational r;
r = 100;
...
}
Our Rational class did not declare an assignment operator that takes an integer parameter. The compiler, then, expects a Rational object on the right-hand side that will be bit-blasted to the left-hand side. The compiler must find a way to convert the integer argument we provided into an object ...
Read now
Unlock full access