vendredi 1 novembre 2019

How to access std::shared_ptr methods

everything is in the title. Im new in C++ and im not sure that I undertand shared_ptr properly...

I've this method:

const std::set<Arret::Ptr, compArret> & getArrets() const;

that I use to get a set of arrets:

auto arrets = unVoyage->second.getArrets();
//(arrets={std::set<std::shared_ptr, Voyage::compArret, std:allocator>})

After that i want to iterate on it with :

for(auto arretCourant = arrets.begin();arretCourant != arrets.end();arretCourant++)

//(so arretCourant =  std::shared_ptr<Arret> referring to the first element in arrets )

My question is how can i access arretCourant methods?

I tried to understand what I was working with by debugging and cout some things :

auto whatIsThat1 = *arretCourant;
cout << "hello" << whatIsThat1; //>> waza0x13fd500

auto whatIsThat2 = arretCourant->get();
cout << "hello" << whatIsThat2; >> waza0x21c2500

Aucun commentaire:

Enregistrer un commentaire