dimanche 1 avril 2018

Difference between "vector" and "Vector" object types

I am fooling around with vectors while running through a C++ book. I have been using "Vector" with an uppercase 'v' by accident. I just noticed in the book they use a lowercase 'v'. I have changed a bunch of my test programs over to use "vector" instead, and other than the color change in my IDE I have yet to discern a difference. As a sidenote I am using a custom header file called "std_lib_facilities.h" which is where I grabbed the definitions from.

The descriptions I get are as follows

vector

//Disgusting macro hack to get a range checked vector:
#define vector Vector

Vector

//Trivially range-checked vector (no iterator checking)
template< class T> struct Vector : public std::vector<T>
{ Whole bunch of code }

My first guess would be the header file I am using just happens to have created its own class named "Vector" of type "vector", to perform what looks like some sort of error handling (I have no idea how to understand most of this header file). My second guess would be the "Vector" is a revised version of "vector", its possible "Vector" hails from the STL and "vector" from old school C. The thing I find interesting is it doesn't seem to matter which one I use. Any ideas?

P.S. The header was provided by Bjarne Stroustrup as part of his Programming Principles and Practice 2ndEd book.

Aucun commentaire:

Enregistrer un commentaire