|
From: Roger F. <ra...@ha...> - 2004-08-26 04:20:47
|
Aloha from Honolulu, Kiryl, My original email had this: >> First: in "Effective C++", item 15, p. 65: >> "operator= default version C& C::operator=(const C&);" >> The & follows the variable (?). I assumed the "C" following "C & C::operator=(const " was the variable--somehow it must have got lost on you. I understand const is a type def. My major concern was with line 8 (below) >> 8: CAT (const CAT &); // copy constructor But as Per W. pointed out in his reply on 8/24/04 8:49PM : > int my_function(int &); > _doesn't_ have the & last, since there is an "invisible" :) parameter name > following it. It is just a lazy short-form of declaration. That the var is invisible was the info I needed. Regarding "lhs" and "rhs", I was confused because "The Complete Reference C++" never seems to use them. Perhaps he's keeping his code as simple as possible for clarity sake. I continue to find his examples most useful in gaining an understanding of the language. (My background was Pascal through the '80s and early '90s--in MSDOS). My thanks for all your help, Per especially. Mahalo, Roger Kiryl V Mauryshchau wrote: > > "operator= default version C& C::operator=(const &);" > > The & follows the variable (?). > > Are you sure that it follows the variable. Maybe what you think is a > variable in fact is a type definition. Check it. > > > 8: CAT (const CAT &); > > Here, "const CAT" is type, not variable. When you _declare_ some > method, you can omit variable. Like in this case. > > > 27: CAT::CAT(const CAT & rhs) > > Here, "const CAT" is type, and "rhs" is variable/object. As I > mentioned before, when you declare a function or method in the class > (.h file), you may omit the variable/object in declaration. But when > you write a function/method itself in implementation file, then you > specify this variable/object. > > I am pretty sure, that in the first example above, what precedes the > ampersand is type. > > Regards, |