#excuse typos. *putput - -> output Rishabh Yadav Junior Undergraduate Department of Electronics Engineering IIT (BHU), Varanasi Varanasi-221005 India
On Fri, Aug 1, 2014 at 12:14 PM, Rishabh Yadav < [email protected]> wrote: > I tried running the following piece of code and expected the putput to be > '''' > hello > hello > '''' > instead the output I'm getting is > '''' > hello > > '''' > > CARD_LIST cl; > std::string s1 = "hello"; > DEV_DOT somedot1; > somedot1.set(s1); > CARD* d = somedot1.clone(); > cl.push_back(d); > std::cout << somedot1.s() << "\n"; > for(CARD_LIST::iterator i=cl.begin(); i!=cl.end(); ++i) > { > DEV_DOT* d = dynamic_cast<DEV_DOT*>(*i); > //assert(d); > std::cout << d->s() << "\n"; > } > > So,the issue is object I get after dynamically typecasting the iterator > variable into DEV_DOT(inside the for loop) doesn't contain the string > information in it meaning the string field in the retrieved DEV_DOT object > is blank. > maybe this was happening because copy constructor of DEV_DOT wasn't > copying the "_s" variable > Felix suggested me to apply a patch to d_dot.h > > -explicit DEV_DOT(const DEV_DOT& p) :CARD(p) {set_constant(true);} > +explicit DEV_DOT(const DEV_DOT& p) :CARD(p), _s(p._s) > {set_constant(true);} > > But even applying the patch didn't help > . > One interesting thing I noted is If I use some print statement in the copy > constructor of DEV_DOT defined in d_dot.h then its not printing > anything.Then I commented out the following line > > explicit DEV_DOT(const DEV_DOT& p) :CARD(p), _s(p._s) { > std::cout << "cloning...\n"; > set_constant(true);} > > from d_dot.h and even after calling somedot.clone() in the above piece of > code, the program compiled successfully. I concluded that somedot.clone() > isn't calling the DEV_DOT copy constructor it's calling the clone from some > other library.Am I correct? > I need your help regarding this matter.Thanks in advance. > Regards, > Rishabh Yadav > Senior Undergraduate > Department of Electronics Engineering > IIT (BHU), Varanasi > Varanasi-221005 > India > _______________________________________________ Gnucap-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnucap-devel
