View Single Post
  #2 (permalink)  
Old 03-29-2008, 04:14 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,650
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default Re: Creating vectors in objects?

Quote:
Originally Posted by MerakSpielman
So the only difference I can think of is that my player_inventory vector is a global vector, but my room_contents vector is inside a "Room" object. Should that really make a difference?
No, it shouldn't. If you've put some objects into the vector inside the same "Room" object, you would still be able to use it, like using the player inventory. It just confuses me, because you say you've made the room inventory almost identical to the player inventory, but it still won't work.

By the way, I noticed you're using the operator[] for your vector; you should rather use vector::at. operator[] does not check whether the given index is out of range or not; vector::at does. If the given index is out of range, vector::at will throw a std:: out_of_range-exception.
Code:
myVector.at(index);
__________________
05-03-2007 - 11-13-2008
Reply With Quote