什么是容器/适配器?我对 C++ 及其子主题(如(类/模板/STL)有基本的了解.
What are containers/adapters? I have basic knowledge of C++ and its sub-topics like (class/templates/STL).
谁能用通俗的语言解释一下,给我一个容器/适配器应用的实际例子?
Can anyone please explain in layman's language and give me a practical example of the application of containers/adapters?
C++ 技术性强,难懂 :-D</joke>
<joke>
C++ is technical and hard to understand :-D</joke>
容器是来自 STL 的数据类型,可以包含数据.
Containers are data types from STL that can contain data.
示例:vector
作为动态数组
适配器是来自 STL 的数据类型,用于适应容器以提供特定接口.
Adapters are data types from STL that adapt a container to provide specific interface.
示例:stack
在所选容器的顶部提供堆栈接口
Example: stack
providing stack interface on top of the chosen container
(旁注:两者实际上都是模板而不是数据类型,但这样的定义看起来更好)
(side note: both are actually templates not data types, but the definition looks better this way)
这篇关于什么是容器/适配器?C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!