重载C ++ STL方法 [英] Overloading C++ STL methods

查看:171
本文介绍了重载C ++ STL方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何重载STL实现的方法,如find,erase和insert取不同的参数?我尝试查找STL方法的重载,但找不到任何帮助。

How can I overload the STL implementation for methods like find, erase and insert to take varying parameters? I tried to look up the overloading of STL methods but couldn't find any help.

推荐答案

编写您自己的免费函数作为辅助函数;它们将使用相关的容器类作为第一个参数。

Write your own free functions that act as helpers; they would take the relevant container class as the first parameter.

你可以继承一个类并添加方法,但std容器类不是设计为继承从。

You can inherit from a class and add methods that way, but the std container classes are not designed to be inherited from.

这篇关于重载C ++ STL方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆