User forums > General (but related to Code::Blocks)

Where is the problem? My code? GCC? CodeBlocks?

(1/2) > >>

cecilio:
I am debugging some code. Execution has arrived to this method:

--- Code: ---void EventNotifier::notify_observers(SpEventInfo pEvent, Observable* target)
{
    std::list<Observer*>::iterator it;
    for (it = m_observers.begin(); it != m_observers.end(); ++it)
    {
        Observable* observedTarget = (*it)->target();
        bool fNotify = (observedTarget == target);
        ...

--- End code ---
The last sentence of previous excerpt has been executed. Both variables, observedTarget and target, have the same value but boolean fNotify is false! (please see attached image)

I have no idea of were is the problem. Any help is greately appreciated. Thank you

Cecilio Salmeron
www.lenmus.org

[attachment deleted by admin]

p2rkw:
Are you using multiple inheritance?

oBFusCATed:

--- Quote from: cecilio on January 15, 2013, 07:39:20 pm ---I have no idea of were is the problem.

--- End quote ---
You've asked the question on the wrong forum... see the details in the rules http://forums.codeblocks.org/index.php/topic,9996.0.html

cecilio:
To p2rkw:

Thank you that's a great clue. I do use inheritance. But both pointers are casted to Observable. How should I do it?


To oBFusCATed
Sorry! When I posted the question I thought it could be something related to Code::Blocks. And the description of the forum is "General (but related to Code::Blocks)
If your post doesn’t fit any of the other topics, post it here :). This is NOT a general programming board.". Sorry again. Please, remove my post if not appropriate. Thank you.



herrtool:
You're comparing addresses, not values.  You mentioned the values are the same but you didn't mention the addresses.  This is a fairly common mistake (I've made it several times).  :)  Dereference the pointers (assuming Observable has an overloaded == operator).

P.S. - Yes, wrong forum but damage is done.  Hopefully this answer solves your problem (or better yet, you've figured it out already).

Navigation

[0] Message Index

[#] Next page

Go to full version