Quote:Original post by c4c0d3m0n
Universität Karlsruhe - Informatik
You should check if your University participates in the MSDNAA (Acadamic Alliance). Then you can get the full version of Visual Studio 2008 for free.
Quote:Original post by c4c0d3m0n
Universität Karlsruhe - Informatik
Quote:Original post by DevFredQuote:Original post by c4c0d3m0n
Universität Karlsruhe - Informatik
You should check if your University participates in the MSDNAA (Acadamic Alliance). Then you can get the full version of Visual Studio 2008 for free.
Quote:Original post by streamer
And what about:
std::vector<R2e::State*>::iterator it = m_state_stack.end();
delete *it;
Quote:Original post by rip-offQuote:Original post by streamer
And what about:
std::vector<R2e::State*>::iterator it = m_state_stack.end();
delete *it;
Undefined behaviour.
std::vector<T>::end() returns a non-dereferenceable (but still comparable) iterator. std::vector<T>::back() is correct.
if ( !m_state_stack.empty() ) { m_state_stack.back()->init( this ); }else{ m_state_stack.push_back( new T ); m_state_stack.back()->init( this );}or simplierif ( m_state_stack.empty() ) { m_state_stack.push_back( new T ); } m_state_stack.back()->init( this );
Quote:Original post by streamerQuote:Original post by rip-offQuote:Original post by streamer
And what about:
std::vector<R2e::State*>::iterator it = m_state_stack.end();
delete *it;
Undefined behaviour.
std::vector<T>::end() returns a non-dereferenceable (but still comparable) iterator. std::vector<T>::back() is correct.
Then if his code is correct, there must be a problem with desctructor.
Quote:Original post by c4c0d3m0n
thanks emeyex! That was indeed the problem, I hadn't set a virtual destructor in the base class. I'm new to this inheritance thing. Thanks again!
Quote:Anyway the code can be defined as:
*** Source Snippet Removed ***
because you are deleting the last element, then pushing on the end
a new element.
You could just skip deleting the last element, and creating the new one, because there is already element on the end, and just initialize it with new values.
Maybe it is not possible, because I don't know what are you doing in Init function, but code looks cleaner.