I get this error message
"error C2440: 'argument' : cannot convert from 'Type' to 'Type &'"
compiling the following piece of code with VC++ 7.1 (w/o language
extensions!):
///////////////////////////////////////////////////////////////////////////
class Type
{
public:
Type ( ) { }
Type( Type& ) { }
};
///////////////////////////////////////////////////////////////////////////////
inline Type operator +
(
Type const&
, Type const&
)
{
Type Result;
return Result;
}
///////////////////////////////////////////////////////////////////////////
inline Type operator -
(
Type const&,
Type const&
)
{
Type Result;
return Result;
}
///////////////////////////////////////////////////////////////////////////////
int main
(
int,
char*
)
{
Type a, b, c;
a - b; // 1
a - b + c; // 2
return 0;
}
///////////////////////////////////////////////////////////////////////////////
Line 1 compiles fine, but line 2 does not. VC++ 7.1 tries to call the
copy ctor in order to compile line 2 and fails. I cannot see the
reason to do so.
Please tell me if this code sould compile accoring to the standard. If
not, explain why.
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|