dimanche 20 décembre 2020

Using standard algorithm library on vectors [closed]

I have created a class called robot (in a robot.h header file) where to create a robot object i will have to initialize it with a robot id,team number,x coordinate , y coordinate. I have then created another header file called robots.h(added a s) where its initialized as just a empty vector of type robot.This is the robots.h file class robots { std::vector<robot> bots; public: void function();} then in my main.cpp i haveint main(){ robots vec;} which is meant use a default constructor for the vector and as such to create a empty vector of object type robot called vec, i have then added some robot objects to that vector "vec". My problem arises when i attempt use any of the commands from the standard algorithm library on that vector of type robot for example if i were to type sort(vec.begin(),vec.end()) or any or any of the other algorithms i would get an error for example in this case when i hover over the sort code it would say " class "robots" has no member "begin" " and unfortunately i haven't been able to figure out what i have been doing wrong (i would say i am still new to c++ so i apologize in advance if my explanation is poor or if i am making a obvious error)

Aucun commentaire:

Enregistrer un commentaire