且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正确的设计模式来处理对象的多态集合

更新时间:2022-06-08 10:47:14

我认为您应该选择选项 1,但改用静态转换.毕竟派生集合肯定知道成员变量的类型.

I think you should go for option 1 but use a static cast instead. After all the derived collection knows the type of the member variable for sure.

这个答案很好地解释了它.