basic iterator problem

Started by
2 comments, last by sfx81 15 years, 4 months ago
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 *'

		}
	}
Advertisement
If you want to get a pointer from an iterator you can use &*itr.
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.
Thankyou very much guys. That was very helpful

This topic is closed to new replies.

Advertisement