c++ - Instantiating objects and object members -


Something like my program does not crash below, but I'm pretty sure it's similar to the design I For, the output is not correct. It does something similar:

  0x537ff4 5471612  

Main program output for indicator address (zero).

The problem can be display_ in the Drv key.

Here's the code:

  #include & lt; Iostream & gt; #include "debug.h" class LCDText {public: int rows_; LCD text () {rows_ = 10; }; }; Class Generic (LCDText * LCDText_Public: Generic (LCD text * LCD text) {LCDTETI = LCD text;}; zero setup () (error ("% p% d", LCDTET_, LCD text _- & gt; Rows_) ;}}; Classroom demonstration: Public LCDtext {generic * Visitor_; public: display (normal * visitor) {visitor_ = visitor;};}; class Dow: public generic {display * display_; public: DRV (): generic (LCD) Takd *) Disple_) {display_ = new Display (normal *) this); }; ~ DRV () {delete_ display_; }; }; Int main () {Drv drv; Drv.Setup (); Return 0; }    

This code:

  Dow () : Generic (LCD-ticked *) display_) {display_ = new display ((Normal *) this); }; Runs the CTOR of the original class with an unpublished value of   

first display_ , then sets the display_ independently, but It is too late to change the original class so the pointer organized by the parent class will never be set correctly. I think you need to add a protected setter method (or parent-class-organized pointer member himself Protect).


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -