home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13284 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.9 KB  |  51 lines

  1. Path: sparky!uunet!mcsun!Germany.EU.net!starlab!mi
  2. From: mi@starlab.UUCP (Michael Hoennig)
  3. Newsgroups: comp.lang.c++
  4. Subject: using this in initializer list generates warning
  5. Summary: should it be allowed to use this befor *this is initialized?
  6. Keywords: this,initialization,base-class pointer
  7. Message-ID: <3927@starlab.UUCP>
  8. Date: 3 Sep 92 06:39:29 GMT
  9. References: <1992Aug29.184025.328@frumious.uucp> <rmartin.715267769@thor> <23598@alice.att.com>
  10. Organization: StarDivision GmbH, D-2000 Hamburg, Germany
  11. Lines: 38
  12.  
  13. In article <23598@alice.att.com> ark@alice.UUCP () writes:
  14.  
  15. >The unfortunate reality is that I have seen a number of development
  16. >projects that have an inflexible rule -- no warnings allowed!  That is,
  17. >they will not allow their people to ship any code that generates warnings.
  18.  
  19. In this context we have a problem with the Microsoft C++ 7.0. We too
  20. should not ship sourch wich generates warnings (but exceptions are
  21. allowed - it's not a strikt rule). But in the following situation 
  22. the MSC7.0 comiler generates a warning: this used befor initialization.
  23.  
  24. class Window;
  25. class Button: public Window ...
  26.  
  27. class Dialog: public Window
  28. {
  29.     Button aBtn;
  30.     ... some more stuff
  31. public:
  32.     Dialog( Window *pParent ):
  33.         Window( pParent ),
  34.         aBtn( this )                // here comes up the warning
  35.     {...}
  36.     ...
  37. };
  38.  
  39. Although I use this as a Window* and the *(Window*)this is already
  40. initialized - the warning comes up. What can we do? To set the parent
  41. after construction is a bad idea it makes code awful and we must
  42. create the Windows on the level of GUI later too because
  43. there are GUI where the parent can't be canged (OLIT, Motif).
  44.  
  45. Adios
  46. -- 
  47. Michael Hoennig                                  FAX:   +49 40 23 646 550
  48. StarDivision GmbH                                Phone: +49 40 23 646 500
  49. Sachsenfeld 4                                    uucp: ...!unido!starlab!mi
  50. D-W-2000 Hamburg 1                               domain: mi@starlab.uucp
  51.