As I understand it the array type is defined, along with the rest of the types, via a class (but I know not which one). Vectors are also defined via a different class. One of the things that makes vectors different is th exact that the vector class includes useful methods and it is stored on the heap. Why can't the array type have methods you design? Better yet why didn't someone think of that before?
Which array are we talking about? The std::array template or the plain array? The std::array has methods.
Standard library algorithms operate generically on range of iterators, not on specific containers. Pointer to element in plain array qualifies as an iterator.
Being new to this I didn't realize there was a difference between std::array and a plain array. I thought there was just one array type, like int, double, etc.
So where is the plain array defined? Is it the same place as int, double? Is in in the math class? If not where.
Where is the std::array defined?
Since these are classes can you not create another class that inherits from the array class and then add your own methods to it? Same with the vector?
It is built in language. There is no definition to it.
Where is the std::array defined?
int header <array>
Since these are classes can you not create another class that inherits from the array class and then add your own methods to it? Same with the vector?
Standard container classes are not intended to be inherited from. However you can create your own Decorator class which would have array/vector member (replacing inheritance with composition) and implement additional capabilities.
I don't know. Since I'm relearning all of this it occurs to me that conceptually you could create a derived class from the vector class and modify to your specifications.
This brings up another confusing thing for me. What is the difference between a class and and template class?
Template is generic boilerplate that the compiler uses to create a class definition. Compile-time polymorphism.
For example, the is no type std::vector, but your code can use types std::vector<int>, std::vector<std::pair<int,std::string>> and std::vector<Person> thanks to templates.
Another example with function templates: std::max(). The library cannot possibly implement a concrete overload of that operation for all possible types that you will write in the future, but the template mechanism can.