Yes, you are correct. I could have set the seed at the top of main() which should have given me a different number of Rects with each run. int main() { srand(time(0)); }
This is a good example, however, using vectors for pointers in not always ideal as if the vector is resized your pointers may become invalid if you do not reserve the space!
You may want to take a look at this: stackoverflow.com/questions/1624803/does-resizing-a-vector-invalidate-iterators and this: stackoverflow.com/questions/6438086/iterator-invalidation-rules In the second post look at the #3 rule about resizing. And if you don't trust SO (for whatever reason) It is also stated in "The C++ Standard Library" by Josuttis, an expert on the STL.
Yes, you are correct. I could have set the seed at the top of main() which should have given me a different number of Rects with each run.
int main()
{ srand(time(0));
}
Bradley, I simply loved it. Never paid any attention to the fact that dynamic_cast would actually give result for subclasses as well.
Also, check out "std::type_index" if you're wanting to use type_info in associate containers ( eg hashmap/std::unordered_map ).
This is a good example, however, using vectors for pointers in not always ideal as if the vector is resized your pointers may become invalid if you do not reserve the space!
You may want to take a look at this:
stackoverflow.com/questions/1624803/does-resizing-a-vector-invalidate-iterators
and this:
stackoverflow.com/questions/6438086/iterator-invalidation-rules
In the second post look at the #3 rule about resizing.
And if you don't trust SO (for whatever reason)
It is also stated in "The C++ Standard
Library" by Josuttis, an expert on the STL.
*****
Thank you! very concise and informative video. :)
good video, you have very nice way of explaining things ... wish you would have posted more such advanced c++ concepts videos
8:17 you said you have already done the casting, where did you do that? thanks
I came to lean Typeid and you threw a lot stuff out that I have 0 idea what is
thanx man just what i was looking for.
I'm guessing you are getting the same number of Rects because you are not changing the seed of the random generator.
Yes
A very good explanation-Pls enlarge the screen size,it's hard to go through all code lines at one go
tf explanation is this .. are you learning yourself? because you dont even fully type the codes dont even get to see them just copy paste the codes