A
ankyhe
I have read C++ Primer 3rd in 2001 and I am reading the 4th edtion of
this book now. I find a bug in the book, chapter 14.9, subtitle is
"Ambiguities When Two Classes Define Conversions". The source code
captured from the book is as follows:
//////////////////////////////////////////////////////////////////////////////////////////
class Integral;
class SmallInt {
public:
SmallInt(Integral); // convert from Integral to SmallInt
// ...
};
class Integral {
public:
operator SmallInt() const; // convert from SmallInt to
Integral
// ...
};
void compute(SmallInt);
Integral int_val;
compute(int_val); // error: ambiguous
//////////////////////////////////////////////////////////////////////////////////////////
The g++ and VC2005(express) will both raise compiler errors for this
section of source code. I think the compiler are correct for:
SmallInt(Integral) use Integral, so this method should see the
Integral definition, not declaration.
I feel sorry I can't find the error list of this book. Could anybody
can tell me where to find the error list of <C++ Primer 4th> or give
me one of the authors email address? Thanks a lot.
this book now. I find a bug in the book, chapter 14.9, subtitle is
"Ambiguities When Two Classes Define Conversions". The source code
captured from the book is as follows:
//////////////////////////////////////////////////////////////////////////////////////////
class Integral;
class SmallInt {
public:
SmallInt(Integral); // convert from Integral to SmallInt
// ...
};
class Integral {
public:
operator SmallInt() const; // convert from SmallInt to
Integral
// ...
};
void compute(SmallInt);
Integral int_val;
compute(int_val); // error: ambiguous
//////////////////////////////////////////////////////////////////////////////////////////
The g++ and VC2005(express) will both raise compiler errors for this
section of source code. I think the compiler are correct for:
SmallInt(Integral) use Integral, so this method should see the
Integral definition, not declaration.
I feel sorry I can't find the error list of this book. Could anybody
can tell me where to find the error list of <C++ Primer 4th> or give
me one of the authors email address? Thanks a lot.