home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13616 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  1.2 KB

  1. Path: sparky!uunet!mcsun!sun4nl!dutrun!dutiws!holland
  2. From: holland@dutiws.tudelft.nl (Gerhard den Hollander)
  3. Newsgroups: comp.lang.c++
  4. Subject: Simple question, sages advice needed
  5. Message-ID: <2100@dutiws.tudelft.nl>
  6. Date: 14 Sep 92 14:45:42 GMT
  7. Organization: Delft University of Technology
  8. Lines: 47
  9.  
  10. Hi,
  11. I have the following (rather simple and stupid) problem.
  12.  
  13. I have a Class A, with a member name (of type MyString).
  14. MyString is just what you'd expect of it,
  15. and contains a friend function operator<<(...);
  16.  
  17. I am currently working with yacc/bizon,
  18. and the following happens.
  19.  
  20. [Note, yacc passes a A* via it's $$ mechanism]
  21.  
  22. Yacc-file (stripped a lot)
  23.  
  24. start : flip flap flop
  25.       {
  26.         cout << *$2 << " Top" << endl;
  27.       }
  28.   
  29. flap  : e f g
  30.       {
  31.          $$ = new A(*$2);
  32.       }
  33.       
  34. f     : e A_POINTER g
  35.       {
  36.         $$ = new A(*$2);
  37.         cout << *$2 << " Bottom" << endl;
  38.       }
  39.       
  40.  
  41. Well after compiling and running this gives
  42. Some.value Bottom
  43. Top
  44.  
  45. My question is,
  46. what happened, why doesn't it say Some.value Bottom
  47. Some.value Top ?
  48.  
  49. Anyone having ideas ??
  50.  
  51. (Oh BTW cout << *$2 is the same as cout << $2->name )
  52.  
  53. Thanks
  54. please reply via email,
  55. I'll gather answers and post a summary
  56.  
  57.