Jump to content
  • Advertisement
Sign in to follow this  
sfx81

basic iterator problem

This topic is 3512 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

Hi. I want to convert the iterator to my type qvec. I tried static_cast, but seems it doesnt like. Any help will be appreciated. Regards Kazz
		
	for(int i = 0; i < 3; i++)
	{
		std::vector<qvec>::iterator itr  = std::find(mVB.begin(), mVB.end(), *arr );
		if(itr == mVB.end())
		{
			mVB.push_back(*itr);
		}
		else
		{
			//qvec* p = (qvec*)itr;  //ERROR.Error	2	error C2440: 'type cast' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'qvec *'

		}
	}

Share this post


Link to post
Share on other sites
Advertisement
An iterator is not a pointer. If you need a pointer, dereference the iterator to get a reference to the object, then use the address-of operator to get a pointer. In other words, &*iter.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!