Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualLudus

Posted 18 April 2013 - 05:38 PM

AAAARRGGGHH apparently you just can't store references in a container like this...

 
Yes, you can, all you need to do is declare that the vector is suppose to store pointers, like this:
 

 

std::vector<Thing*>    myVector;
 

 

Take note of the asterisk. This will store an array of pointers for "Thing" into otherVector. The way you have it set up right now, otherVector is in fact storing an array of "Thing" objects themselves, rather than references to them.


#2Ludus

Posted 18 April 2013 - 12:58 PM

AAAARRGGGHH apparently you just can't store references in a container like this...

 
Yes, you can, all you need to do is declare that the vector is suppose to store pointers, like this:
 

 

std::vector<Thing*>    otherVector;
 

 

Take note of the asterisk. This will store an array of pointers for "Thing" into otherVector. The way you have it set up right now, otherVector is in fact storing an array of "Thing" objects themselves, rather than references to them.


#1Ludus

Posted 18 April 2013 - 12:54 PM

AAAARRGGGHH apparently you just can't store references in a container like this...

 
Yes, you can, all you need to do is declare that the vector is suppose to store pointers, like this:
 

 

std::vector<Thing*>    otherVector;
 

 

Take note of the asterisk. This will store an array of pointers for "Thing" into otherVector.


PARTNERS