AggrorJorn Posted August 18, 2012 Posted August 18, 2012 I want to make a simple iteration through a vector, yet I get the error that operator is not matching the operands. //.h vector<resolution*> resolutionList; //.CPP resolutionList.push_back(new resolution(640,480,resolution.Ratio._4_3_)); vector<resolution>::iterator i; for(i = resolutionList.begin(); i != resolutionList.end(); ++i) { What am I doing wrong here? Quote
Furbolg Posted August 18, 2012 Posted August 18, 2012 Hi Aggror, in the h. file you use: vector<resolution*> and in the cpp. file you use vector<resolution> thats a difference Quote
AggrorJorn Posted August 18, 2012 Author Posted August 18, 2012 Lol. Took me half an hour. How could I have missed that? Thanks for the help. Quote
Roland Posted August 18, 2012 Posted August 18, 2012 Just to avoid those mistakes ( happens even so often ) I usually add a typedef like this //.h typedef vector<resolution*> ResolutionList; ResolutionList resolutionList; //.CPP resolutionList.push_back(new resolution(640,480,resolution.Ratio._4_3_)); ResolutionList::iterator i; for(i = resolutionList.begin(); i != resolutionList.end(); ++i) { Quote Roland Strålberg Website: https://rstralberg.com
TheoLogic Posted August 20, 2012 Posted August 20, 2012 Or use auto if your compiler support this C++11 feature std::vector<Resolution*> ResolutionList; //... for(auto it(ResolutionList.begin()); it != ResultionList.end(); ++it) { /*...*/ } 1 Quote Follow me
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.