STD problem?

This is a discussion on STD problem? within the C++ Programming forums, part of the General Programming Boards category; I really don't know what's wrong with this code, and I can't find what's wrong with it. I have Code: ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    97

    STD problem?

    I really don't know what's wrong with this code, and I can't find what's wrong with it.
    I have
    Code:
    std::vector <Light_Point *> visible_pointlights;
    and in a function I determine what lights are visible from the current position. Once that is determined what I do is
    Code:
    visible_pointlights.push_back(entities[i]->pointlight);
    entities[i]->pointlight is a Light_Point too. Among some other data, Light_Point contains 3 floats called x, y and z. The problem is that the values in visible_pointlights[i] are not the same as entities[i]->pointlight.
    I really don't know why it doesn't work because I'm pointing at the sime thing.
    Also, in case you need to know entities[i].pointlight is defined as
    Code:
    Light_Point * pointlight;
    I hope that helps determine what's wrong with my code.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Post the code that checks the element inside the vector container to that in entities array.

    Sounds like there is an order problem.

    Kuphryn

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    97
    Actually I'm just checking the values for entities[i]->pointlight and visible_pointlights to see if the values are right(in the Autos window of MSVS). So even if the the order was wrong, I should still see the same values. I'm really wondering why is it pointing to a wrong location.

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    97
    I guess I'll have to rewrite the code in hopes that it works again.

  5. #5
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    That strange...What specific compiler error are you getting?
    01000111011011110110111101100100 011101000110100001101001011011100110011101110011 01100100011011110110111001110100 01100011011011110110110101100101 01100101011000010111100101110011 0110100101101110 01101100011010010110011001100101
    Good things donīt come easy in life!!!

  6. #6
    Registered User
    Join Date
    Oct 2003
    Posts
    97
    Originally posted by ripper079
    That strange...What specific compiler error are you getting?
    No, there is no compiler errror, everything compiles fine. But when I draw the lights I see the values are wrong, then I check out the values in the debugger and they are wrong, they are not the values that I'm supposed to get from visible_pointlights.push_back(entities[i]->pointlight) . The values of visible_pointlights are not the same as the ones in entities[i]->pointlight.

  7. #7
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Posting more code is still probably the best way for someone to help you. Ideally, a small compilable example that illustrates your problem would be best. Otherwise, at lease show the functions that change the data in those data structures, as well as all the code that you are stepping through when you notice the incorrect values.

    Also, using the debugger to step through the code should help you.

  8. #8
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    I must agree with jlou. Post more relevant code. Step through the code when you for the first time pushes to the vector and see it both values are the same. You are probably changing visible_pointlights or entities->pointlight values and not updating the corresponding datastructure. They must work synchronized or else it will not work. Remember that std::vector objects are stored as copies!
    01000111011011110110111101100100 011101000110100001101001011011100110011101110011 01100100011011110110111001110100 01100011011011110110110101100101 01100101011000010111100101110011 0110100101101110 01101100011010010110011001100101
    Good things donīt come easy in life!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem in calling DLL
    By bhagwat_maimt in forum C++ Programming
    Replies: 2
    Last Post: 11-19-2006, 09:43 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  3. array problem?
    By ssjnamek in forum C Programming
    Replies: 14
    Last Post: 02-08-2006, 05:03 PM
  4. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  5. Problem with std lists and my ships
    By Vorok in forum Game Programming
    Replies: 1
    Last Post: 01-15-2003, 06:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21