Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我们有一个基类green和这样的层次结构树:
green
我们有一个列表,greenList里面有所有的类red,blue等等green。我们不创建这个列表,我们给它填充了数据。我们现在要为等类创建red列表yellow。我们确实有red等类的标题,我们不希望有getType内部green类。
greenList
red
blue
yellow
getType
如何将该列表排序到C++03 中的greenList列表等redList列表中(使用 boost)?yellowList
redList
yellowList
如果是指针,使用 dynamic_cast 并检查返回值;如果它们是 refs,则在 try/catch 块内使用动态转换。