Re: [Dev-C++] ostringstream and insertion operator problem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: A D <a_...@ho...> - 2007-11-02 00:12:32
|
Thanks for your reply.=20 =20 =20 > Jonathan wrote: > A reference to an object is actually a pointer, which is a number (to whi= ch > we have attached a special meaning) > Testing this reference tests the pointer with 0, or NULL. I think you wil= l > find that << returns NULL if it fails. =20 Still it's not clear to me. So you are sayin' that a function that returns = a reference type can return NULL for that same purpose. Suppose there's a code like thi= s: =20 #include=20 =20 class Aa { public: int i; Aa& aFunc(); }; =20 Aa& Aa::aFunc() { =20 return NULL; } =20 int main() { Aa firstObj; =20 firstObj.aFunc(); return 0; } =20 aFunc() function supposed to return NULL. But i get the following compilati= on=20 error: =20 test.cc: In member function =91Aa& Aa::aFunc()=92: test.cc:13: error: invalid initialization of non-const reference of type = =91Aa&=92=20 from a temporary of type =91int=92 =20 if a function can return a NULL value instead of a reference value why this= code=20 and this function spewing this error?=20 =20 _________________________________________________________________ R U Ready for Windows Live Messenger Beta 8.5? Try it today! http://entertainment.sympatico.msn.ca/WindowsLiveMessenger= |