Hi,
Well technically the compiler handles the reference part, so you would have
to return an object, and the compiler would make that a reference.... So I'm
not sure how this NULL thing pans out in the end...
Ok well it seems I misleaded you...
>From here: http://www.cppreference.com/cppio/examples.html
"""Simply evaluating an I/O object in a boolean context will return false if
any errors have occurred:"""
Which is actually whet the test was all about.
Sorry about that,
Jonathan
On 11/2/07, A D <a_...@ho...> wrote:
>
>
> Thanks for your reply.
>
>
> > Jonathan wrote:
> > A reference to an object is actually a pointer, which is a number (to
> which
> > we have attached a special meaning)
> > Testing this reference tests the pointer with 0, or NULL. I think you
> will
> > find that << returns NULL if it fails.
>
> 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
> this:
>
> #include
>
> class Aa
> {
> public:
> int i;
> Aa& aFunc();
> };
>
> Aa& Aa::aFunc()
> {
> return NULL;
> }
>
> int main()
> {
> Aa firstObj;
>
> firstObj.aFunc();
> return 0;
> }
>
> aFunc() function supposed to return NULL. But i get the following
> compilation
> error:
>
> test.cc: In member function 'Aa& Aa::aFunc()':
> test.cc:13: error: invalid initialization of non-const reference of type
> 'Aa&'
> from a temporary of type 'int'
>
> if a function can return a NULL value instead of a reference value why
> this code
> and this function spewing this error?
>
>
> _________________________________________________________________
> Are you ready for Windows Live Messenger Beta 8.5 ? Get the latest for
> free today!
> http://entertainment.sympatico.msn.ca/WindowsLiveMessenger
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
--
<Morpheus> linux, c'est une question de VI ou de MORE
|