Topic: Help! Confused about operator overloading


Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Mon, 1 Nov 1993 03:01:15 GMT
Raw View
In article <CFAoCx.5n9@cs.uct.ac.za> agodfrey@cs.uct.ac.za (Andrew Godfrey) writes:
>In <CF9tJy.5Mn@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
>
>>From article <CF9L1r.CGt@cs.uct.ac.za>, by agodfrey@cs.uct.ac.za (Andrew Godfrey):
>>>...
>>> I would like to know about the line
>>>  return complex( .....  );
>>>
>>> What is this complex() it's talking about?
>> A brand new one.
>
>[stuff deleted]
>
>Well, now I understand that a constructor does not have the same sort of scope
>as a member function, in that you call a member function via obj.member(),
>while it seems you can call a constructor via constructor().

This brings up an interesting point.  Given some type `T', is an expression
like `T(expression)' really a constructor call (12.1) or is it really a
function-like cast (5.2.3).  I for one don't know.  Worse yet, I can't
even tell if there is any difference between these two things, even though
they are described in two different parts of the ARM.

It looks like there may indeed be some sort of distinction between these
two things.  In the case of constructor-calls, the thing in front of the
parens has to be a "class-name" (12.1).  In the case of a function-like
cast however (5.2.3) it must be a "simple-type-specifier".

But a "simple-type-specifier" may be a "qualified-class-specifier" which
may in turn be a "nested-class-specifier" which may in turn be a "class-name".

If anyone is NOT confused by this stuff, please say so.

(Follow-ups to comp.std.c++ please.)

--

-- Ronald F. Guilmette, Sunnyvale, California -------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------