Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

odd const

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

void Node::validateHierarchy( bool forceUpdate ) const //   here are problem
{
	if ( (m_flag & NODE_WORLDDIRTY) || forceUpdate )
	{
		// compute model->world transform
		Node* parent = this->parent();
		if ( parent )
			m_worldTransform = parent->m_worldTransform * m_localTransform;
		else
			m_worldTransform = m_localTransform;
		
		m_flag &= ~NODE_WORLDDIRTY;
		forceUpdate = true;
	}

	std::vector<Node*>::iterator it, begin, end;
	begin = m_child.begin();//   here are problem
	end = m_child.end();

	for ( it = begin;it != end; it++)
		it.validateHierarchy( forceUpdate );
}

If I use const ,C2679 error up. why???

Share this post


Link to post
Share on other sites
Advertisement
A const member function automatically treats all member variables as const. Furthermore, you can only call other const member functions (or static member functions).

Share this post


Link to post
Share on other sites
Another thing:


// This is not good. You're using the post-increment operator even tho you
// you're not interested in its return value at all. Use the more efficient
// pre-incremement operator instead.
//for ( it = begin;it != end; it++) // not good
for ( it = begin;it != end; ++it ) // better
it.validateHierarchy( forceUpdate );

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!