Comparing vector elements or address?

Mar 27, 2017 at 8:39pm
I want to compare the actual object stored in the vector. I was wondering if this is comparing the address or the value of the object in the vector. The > operator has been overloaded for this object. I was under the assumption i was suppose to use * instead of & in this situation. Any clarification will be much appreciated.
selectedHandB and selectedHandA are pointers
1
2
3
4
if((&selectedHandB)[0] > (&selectedHandA)[0])
    {
        std::cout << " B > A " << std::endl;
    }
Mar 27, 2017 at 8:49pm
> I was under the assumption i was suppose to use * instead of & in this situation.
don't guess, think.


> I want to compare the actual object stored in the vector.
> selectedHandB and selectedHandA are pointers
¿how are they related to the vector?
¿where is the vector?
Mar 27, 2017 at 8:52pm
Vector was already created then i called a function to determine which cards the player wants to use. If the player selects one card its gonna be the very first in the vector which is what im comparing.

1
2
3
4
selectedHandA = selectHandToPlay(*lowestCardInPlay.playerA);
    std::cout << "You have selected:" << std::endl;
    printPlayerHand(selectedHandA);
    selectedHandB = selectHandToPlay(*lowestCardInPlay.playerB);
Mar 27, 2017 at 10:05pm
it looks like you just need to boil it down to

vector1[0] > vector2[0]

and throw all the pointers out of the code. Unless you need them for something else.

Edit: and you have this same question up at least 3 times. Please don't do that. It is not necessary to clutter up the boards; everyone sees the same posts in all the forums and will help you when they can.


Last edited on Mar 27, 2017 at 10:06pm
Mar 28, 2017 at 2:42am
Looks like this was actually posted twice. I'm not sure how that happen as it was unintentional
Last edited on Mar 28, 2017 at 3:10am
Topic archived. No new replies allowed.