Hi,
I would like to know how to add the objects of a vector?I wrote a code where it is adding the values to a specific object.I wanted to write a code where it can add all the values of all objects in a vector?
sita12345
0
Newbie Poster
Recommended Answers
Jump to Poststruct object { char beer; }temp_object; for(int i=0; i<69; i++) { temp_object.beer = value; my_vector.push_back(temp_object); } //now change it for(int i=0, size=my_vector.size(); i<size; i++) { my_vector[i].beer = another_value; }
Jump to Postvector<int> my_vector; for(int i=0; i<69; i++) { my_vector.push_back(i); } //now change it for(int i=0, size=my_vector.size(); i<size; i++) { my_vector[i] *= 2; }
All 5 Replies
Clinton Portis
211
Practically a Posting Shark
sita12345
0
Newbie Poster
Clinton Portis
211
Practically a Posting Shark
sita12345
0
Newbie Poster
Clinton Portis
211
Practically a Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.