home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11501 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.1 KB  |  37 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!murdoch!virginia.edu!gs4t
  3. From: gs4t@virginia.edu (Gnanasekaran Swaminathan)
  4. Subject: Re: classes referenced each in their declaration
  5. Message-ID: <1992Jul24.225524.15961@murdoch.acc.Virginia.EDU>
  6. Sender: usenet@murdoch.acc.Virginia.EDU
  7. Reply-To: gs4t@virginia.edu (Gnanasekaran Swaminathan)
  8. Organization: University of Virginia
  9. References: <1992Jul23.003724.13021@virginia.edu> <712032673snx@trmphrst.demon.co.uk>
  10. Date: Fri, 24 Jul 1992 22:55:24 GMT
  11. Lines: 24
  12.  
  13. nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
  14. |> gs4t@virginia.edu (Gnanasekaran Swaminathan) writes:
  15. |> Thanks for catching the bug. The following is tested
  16. |> in GNU C++ and it works.
  17. |>
  18. |> class Y;
  19. |> 
  20. |> class X {
  21. |>     Y&    y;
  22. |>     public:
  23. |>     X(const Y& y1): y(y1) {}
  24. |> };
  25. |Is it permissible to assign a reference to const to a reference to non-
  26. |const in GNU C++ ?
  27. |
  28. |I don't think it should be !
  29.  
  30. You are right. It is a bug in the GNU C++ compiler.
  31. GNU C++ didn't catch it.
  32.  
  33. You can either change the copy constructor to be X(Y& y1): y(y1) {}
  34. or define the member y to be const Y& y; to correct the program
  35.  
  36. -Sekar
  37.