- Where Developers Learn, Share, & Build Careers


I want to store the indicators in a deck that looks like this:

deck & Lt; OfImage * & gt; Pointer Dick;

  Zero testApp :: iTakeAPointer (iGes * and Pointer) {cout & lt; & Lt; "ITAKAPointer" & lt; & Lt; & Amp; Pointer & lt; & Lt; Endl; PointerDeque.push_back (pointer); Cout & lt; & Lt; "Pointerdec.back ()" & lt; & Lt; PointerDeque.back () & lt; & Lt; Endl; }   

When I run it, I get it (the function is called on the queset):

  key pressed 0xbffff240 iTakeAPointer 0xbffff240 pointerdek.back () 0x9f2e08   

Because deque.push_back () creates a copy My question is: How can I get reference to 0xbffff240 in this context, in the deck?

Edit:

Thanks. Sometimes you do not see wood for trees.

Your diagnosis is incorrect. This is printing the address of the pointer, not the address that holds the pointer (which you want):

  cout & lt; & Lt; "ITAKAPointer" & lt; & Lt; & Amp; Pointer & lt; & Lt; Endl;   

and pointer is the type of ofImage ** . Just use the pointer :

  cout & lt; & Lt; "ITAKAPointer" & lt; & Lt; Indicator & lt; & Lt; Endl;   

Note that there should be present in ofImage example PointerDeque exist for your lifetime if the PointerDec now has ofImage examples, then consider using std :: unique_ptr . If it is not self, consider using std :: shared_ptr (or boost :: shared_ptr ).

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -