const vector<Rect> rects(2) = vector<Rect>(Rect(0,0,333,333),Rect(0,0,333,333));
Please help!
[edited by - Zeblar Nagrim on November 15, 2003 4:39:18 AM]
const vector
How to initialize a const vector?
I want to add 2 elements of my Rect class to a vector.
Something like this (doesn't work):
Here is the lazy pachy solution (dono how else to do it, but I bet theres a better way):
"Stop trying to hit me and hit me!"
vector<Rect> tmp;tmp.push_back(Rect(0,0,333,333));tmp.push_back(Rect(0,0,333,333));const vector<Rect> rects=tmp;
"Stop trying to hit me and hit me!"
quote:Original post by emileej
Here is the lazy pachy solution (dono how else to do it, but I bet theres a better way):
vector<Rect> tmp;tmp.push_back(Rect(0,0,333,333));tmp.push_back(Rect(0,0,333,333));const vector<Rect> rects=tmp;
"Stop trying to hit me and hit me!"
Thanks!
How about:
A bit overly explicit there, just in case...
[edited by - Null and Void on November 15, 2003 4:58:42 AM]
#include <cstddef>#include <vector>int main() { const int something_init[] = { 1, 2, 3 }; const std::size_t something_size = sizeof(something_init)/sizeof(*something_init); std::vector <int> something(something_init, &something_init[something_size]); // ...}
A bit overly explicit there, just in case...
[edited by - Null and Void on November 15, 2003 4:58:42 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement