C++ - typeid and dynamic_cast

Поділитися
Вставка
  • Опубліковано 17 гру 2024

КОМЕНТАРІ • 15

  • @bradleyneedham1666
    @bradleyneedham1666  11 років тому +6

    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));
    }

  • @ashwanithakur4813
    @ashwanithakur4813 9 років тому +1

    Bradley, I simply loved it. Never paid any attention to the fact that dynamic_cast would actually give result for subclasses as well.

  • @matt_7670
    @matt_7670 5 років тому

    Also, check out "std::type_index" if you're wanting to use type_info in associate containers ( eg hashmap/std::unordered_map ).

  • @s.d.gentry1354
    @s.d.gentry1354 8 років тому +2

    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!

    • @s.d.gentry1354
      @s.d.gentry1354 8 років тому

      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.

    • @s.d.gentry1354
      @s.d.gentry1354 8 років тому

      *****

  • @matt_7670
    @matt_7670 8 років тому +1

    Thank you! very concise and informative video. :)

  • @threelittlefoxproductions
    @threelittlefoxproductions 11 років тому

    good video, you have very nice way of explaining things ... wish you would have posted more such advanced c++ concepts videos

  • @Israel9068
    @Israel9068 7 років тому

    8:17 you said you have already done the casting, where did you do that? thanks

  • @FlameHashiraAries
    @FlameHashiraAries 5 років тому +2

    I came to lean Typeid and you threw a lot stuff out that I have 0 idea what is

  • @KZ-si4wm
    @KZ-si4wm 3 роки тому

    thanx man just what i was looking for.

  • @juanjcp27
    @juanjcp27 11 років тому +4

    I'm guessing you are getting the same number of Rects because you are not changing the seed of the random generator.

  • @vaibhavgupta6u
    @vaibhavgupta6u 11 років тому

    A very good explanation-Pls enlarge the screen size,it's hard to go through all code lines at one go

  • @jenishshrestha2895
    @jenishshrestha2895 5 років тому

    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