Advertisement Jump to content


This topic is now archived and is closed to further replies.


Pointers and STL containers

This topic is 6179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Given the defintition;
	// In Game BOBs

	lpBOB			mousepointer;
	lpBOB			sheep;
	lpCharacter		player;
	lpGSTATE		gstate;
	//iCOORD			test;

} GameG ; 
and that the GSTATE class contains an object map of type vector. I use the following declarations to create a pointer to the vector:
GameG.gstate = new GSTATE(iTempWidth, iTempWidth);
vector<int>* ivMap = &GameG.gstate->map;
What does ivMap really point to? I was expecting ivMap[someint] to return the contents of the approipriate location within the gstate->map array/vector. Instead I get goobledigook.

Share this post

Link to post
Share on other sites
You need to dereference the pointer. Use the form


Very simple ideas lie within the reach only of complex minds.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!