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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!slsvaat!slsvitt!dcb
  3. From: dcb@slsvitt (David Binderman 3841)
  4. Subject: ARM code don't work
  5. Message-ID: <1992Sep14.181108.8639@us-es.sel.de>
  6. Summary: cfront 3.1 ready yet ?
  7. Sender: news@us-es.sel.de
  8. Organization: SEL-Alcatel LTS Dept. US/ES
  9. X-Newsreader: Tin 1.1 PL4
  10. Date: Mon, 14 Sep 92 18:11:08 GMT
  11. Lines: 70
  12.  
  13. Hello there,
  14.  
  15. I tried the code from pages 292 and 293 of the ARM on various C++ compilers.
  16.  
  17. I found that cfront 2.1, cfront 3.0, GNU 1.39, GNU 222 all got the same answer.
  18.  
  19. Unfortunately, not the same answer as the ARM.
  20.  
  21. Can anyone tell me which is right ?
  22.  
  23. results are
  24.  
  25. B ctor
  26. A ctor
  27. C ctor
  28. D ctor
  29. E ctor
  30.  
  31. ARM claims
  32.  
  33. A ctor
  34. B ctor
  35. C ctor
  36. D ctor
  37. E ctor
  38.  
  39. Code follows
  40.  
  41. ---------------------- cut here --------------------------------------
  42. extern "C" {
  43.     int printf( const char *, ...);
  44. };
  45.  
  46. class A {
  47. public:
  48.     A() { printf( "A ctor\n"); };
  49. };
  50.  
  51. class B {
  52. public:
  53.     B() { printf( "B ctor\n"); };
  54. };
  55.  
  56. class C : public virtual A, public virtual B {
  57. public:
  58.     C() { printf( "C ctor\n"); };
  59. };
  60.  
  61. class D : public virtual B, public virtual A {
  62. public:
  63.     D() { printf( "D ctor\n"); };
  64. };
  65.  
  66. class E : public C, public D {
  67. public:
  68.     E() { printf( "E ctor\n"); };
  69. };
  70.  
  71. int main() {
  72.     E e;
  73.     return 0;
  74. }
  75.  
  76. -------------------- cut here ----------------------------------------
  77.  
  78. Regards
  79. --
  80. David C Binderman  Dept US/ESI, Bau 60, SEL-Alcatel AG, Lorenz Strasse 10,
  81. D-7000 Stuttgart 40, Germany     dcb@us-es.sel.de    +49 711 821 3841
  82. If you lie to the compiler, it will gets its revenge
  83.