Jump to content

Image of the Day

#animation 2/14

Sweet piggy, isn't it?

#gamedev #indiedev #indiegame #GamersUnite #screenshotsaturday #unity3d https://t.co/lscyvCxrPR
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

Weird C++ problem

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Aliii   Members   

1456
Like
0Likes
Like

Posted 21 June 2013 - 03:37 PM

Here is this piece of code:

    for( list<CObjectParent*>::const_iterator i = object_parent_list.begin(); i != object_parent_list.end(); ++i)
        if( (*i)->select( cam_pos, curs_pos, &min_distance, &p_aimed_object))
            aimed_something = true;

This shouldnt compile because CObjectParent.select(...) is not const. But it works.

Also the debugger is being weird. I run the program in debug mode, it works as it should(more or less) but when I stop it at a random breakpoint and i step through a few lines it gives weird errors.

 

Untitled.png

 

See the pic. It said this to the PushMatrix line: "Type std::list<CObjectInstance*, std::allocator<CObjectInstance*> > has no component named object_instance_list."

Sometimes it says segmentation fault bla-bla. Ive been checking the code all day but everything seems to be OK. Help would be really appreciated.

My IDE is NetBeans and the compiler is GCC(using the C++11 standard)



#2 SiCrane   Moderators   

11665
Like
6Likes
Like

Posted 21 June 2013 - 03:48 PM

*
POPULAR

When you use a const_iterator on a container of pointers, you can't change the pointers. So you can't do *i = some_new_pointer; You can still change object that those pointers point to because the pointers are pointers to non-const objects.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.