However, when I run this, it's giving lots of errors:
..\src\sample.cpp:8:7: error: expected nested-name-specifier before 'vector'
using vector<T>::vector; // inherit constructors
^
..\src\sample.cpp:9:16: error: declaration of 'operator=' as non-function
T& operator=[](size_type i) { check(i); return this->elem(i); }
^
..\src\sample.cpp:9:14: error: expected ';' at end of member declaration
T& operator=[](size_type i) { check(i); return this->elem(i); }
^
..\src\sample.cpp:9:26: error: expected ')' before 'i'
T& operator=[](size_type i) { check(i); return this->elem(i); }
^
..\src\sample.cpp:10:20: error: declaration of 'operator=' as non-function
const T& operator=(size_type i) const { check(i); return this->elem(i); }
^
..\src\sample.cpp:10:18: error: expected ';' at end of member declaration
const T& operator=(size_type i) const { check(i); return this->elem(i); }
^
..\src\sample.cpp:10:30: error: expected ')' before 'i'
const T& operator=(size_type i) const { check(i); return this->elem(i); }
^
..\src\sample.cpp:11:12: error: 'size_type' has not been declared
void check(size_type i) { if (this->size()<i) throw Bad_index(i); }
^
..\src\sample.cpp: In member function 'void Vector<T>::check(int)':
..\src\sample.cpp:11:64: error: there are no arguments to 'Bad_index' that depend on a template parameter, so a declaration of 'Bad_index' must be available [-fpermissive]
void check(size_type i) { if (this->size()<i) throw Bad_index(i); }
^
..\src\sample.cpp:11:64: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
I am new in Inheriting classes, and I can't believe this has many errors. Is there something wrong with the book?
..\src\sample.cpp: In member function 'void Vector<T>::check(int)':
..\src\sample.cpp:11:64: error: there are no arguments to 'Bad_index' that depend on a template parameter, so a declaration of 'Bad_index' must be available [-fpermissive]
void check(size_type i) { if (this->size()<i) throw Bad_index(i); }
^
Basicly compiler does not know what Bad_index is. Make sure that it is declared before use