Iterating through a vector of pointers

后端 未结 3 1171
青春惊慌失措
青春惊慌失措 2020-12-28 17:03

I\'m trying to iterate through a Players hand of cards.

Player.cpp

vector::iterator iter;
    for(iter = current_car         


        
3条回答
  •  孤城傲影
    2020-12-28 17:53

    De-referencing the iterator by iter-> gives a pointer to an object of type Card, you have to write (*iter)->display_card();

提交回复
热议问题