home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13714 < prev    next >
Encoding:
Text File  |  1992-09-15  |  1.1 KB  |  32 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!jdl47513
  3. From: jdl47513@uxa.cso.uiuc.edu (Jason Lowe)
  4. Subject: Problems with reference function and consts
  5. Message-ID: <Bun6vx.BtJ@news.cso.uiuc.edu>
  6. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  7. Organization: University of Illinois at Urbana
  8. Date: Tue, 15 Sep 1992 23:07:03 GMT
  9. Keywords: const
  10. Lines: 20
  11.  
  12. I am sorry if this is in a FAQ somewhere...
  13.  
  14. I have a class that overloads the [] operator, returning a reference to type
  15. int.  I also have a const declared ie:
  16.  
  17. const errorval = -1;
  18.  
  19. When I try to return errorval in the overloaded operator[] function, CC gives
  20. me a warning about temporary variable reference (not lvalue or incorrect type)
  21.  
  22. If I ignore the warning, the code runs incorrectly.  Is it possible to return
  23. a reference to a const?  If so, what is wrong?  Please email and thanks in
  24. advance!
  25.  
  26.  
  27.  
  28. -- 
  29. Jason Lowe      |   //       | Take the Oath.  Watch Ren and Stimpy!
  30. stimpy@uiuc.edu | \X/ Amiga! | "And look, he's beating up on our cheese!"
  31.  
  32.