什么是容器/适配器?C++

2024-08-13C/C++开发问题
4

本文介绍了什么是容器/适配器?C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

什么是容器/适配器?我对 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++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&amp;()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6