[ create a new paste ] login | about

Link: http://codepad.org/lTXkoSwF    [ raw code | output | fork ]

C++, pasted on Jan 20:
#include <iostream>
#include <vector>
using namespace std;

template <class T>
struct MyVector : public vector<T>
{
    T & operator[](unsigned i)
    {
        return vector<T>::at(i);
    }
};

#define vector MyVector

int main()
{
    vector<int> v;

    v.push_back(2);	

    cout << v[0] << endl;
    cout << v[1] << endl;

    return 0;
}


Output:
1
2
3
2
std::out_of_range: vector::_M_range_check
Aborted.


Create a new paste based on this one


Comments: