Noob在这里,
我正在尝试从Bjarne Stroustrup的'The C++ Programming Language'编译这段代码,但CodeBlocks一直在向我抛出这个错误.
代码是关于范围检查向量函数中保存的数组.
这是代码:
#include <iostream>
#include <vector>
#include <array>
using namespace std;
int i = 1000;
template<class T> class Vec : public vector<T>
{
public:
Vec() : vector<T>() { }
T& operator[] (int i) {return at(i); }
const T& operator[] (int i) const {return at(i); }
//The at() operation is a vector subscript operation
//that throws an exception of type out_of_range
//if its argument is out of the vector's range.
};
Vec<Entry> phone_book(1000);
int main() …Run Code Online (Sandbox Code Playgroud)