dynamic_cast not throwing exceptions as expected

后端 未结 2 1814
-上瘾入骨i
-上瘾入骨i 2021-01-26 00:55

Based on this answer...

Finding the type of an object in C++

...I wrote this code:

        static TVALUE getUpperBou         


        
2条回答
  •  清酒与你
    2021-01-26 01:46

    You are casting to a pointer. bad_cast is only generated when casting to a reference.

    You can just check for nullptr if casting to a reference isn't desirable.

提交回复
热议问题