c++ - 3 errors: error: 'Entry' was not declared in this scope. error: template argument 1 is invalid. error: invalid type in declaration before '(' token -


noob here, sorry error filled title.

i'm trying compile segment of code bjarne stroustrup's 'the c++ programming language' codeblocks keeps throwing me error.

the code range checking array held in vector function.

#include <iostream> #include <vector> #include <array>  using namespace std;  int = 1000;  template<class t> class vec : public vector<t> { public:     vec() : vector<t>() { }      t& operator[] (int i) {return vector<t>::at(i); }     const t& operator[] (int i) const {return vector<t>::at(i); }     //the at() operation vector subscript operation      //that throws exception of type out_of_range     //if argument out of vector's range. };  vec<entry> phone_book(1000); //this line giving me trouble  int main() {      return 0; } 

it's giving me these errors:

  • error: 'entry' not declared in scope.
  • error: template argument 1 invalid.
  • error: invalid type in declaration before '(' token.

what have change? how declare vec entry ?

honestly, doubt directly copied piece of code bjarne. however, problem error says: entry not declared. if want play around example, can try example

vec<int>  

instead. however, there small problem (and 1 makes me believe changed bjarnes code): class vec has no constructor takes int, thus

vec<int> phone_book(1000);  

cannot work. supply constructor:

vec(int size) : vector<t>(size) {} 

and should work.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -