=====Vector operators===== Syntax: #include TYPE& operator[]( size_type index ); const TYPE& operator[]( size_type index ) const; vector& operator=(const vector& c2); bool operator==(const vector& c1, const vector& c2); bool operator!=(const vector& c1, const vector& c2); bool operator<(const vector& c1, const vector& c2); bool operator>(const vector& c1, const vector& c2); bool operator<=(const vector& c1, const vector& c2); bool operator>=(const vector& c1, const vector& c2); All of the C++ containers can be compared and assigned with the standard comparison operators: ==, !=, %%<=%%, >=, <, >, and =. Individual elements of a vector can be examined with the [] operator. Performing a comparison or assigning one vector to another takes [[/complexity|linear time]]. The [] operator runs in [[/complexity|constant time]]. Two vectors are equal if: - Their size is the same, and - Each member in location i in one vector is equal to the the member in location i in the other vector. Comparisons among vectors are done lexicographically. For example, the following code uses the [] operator to access all of the elements of a vector: vector v( 5, 1 ); for( int i = 0; i < v.size(); i++ ) { cout << "Element " << i << " is " << v[i] << endl; } Related Topics: [[at]]