SequenceContainer base class?

Viewed 84

In Java all containers are in a hierarchy of abstract base classes:

List<String> v1 = new LinkedList<String>();
AbstractSequentialList<String> v2 = new LinkedList<String>();

Is there an analogue for SequenceContainer and std::vector in C++?

1 Answers

No, std::vector has no (standard, documented) base class, nor does it have any virtual methods. The C++ standard library doesn't use runtime polymorphism much aside from the iostream classes.

The C++ standard library is geared more towards static, compile-time polymorphism with templates. SequenceContainer is just a name for the way some set of classes can be interacted with. The intent is that you can write template code that interacts with objects only by that documented interface and it will work with any class that fulfills those requirements.

Related