c++ - Why can't I put namespace in parent class constructor call? -
so know doing wrong according purists, inheriting std::vector, wanted add specific functionality think has lot of sense child of vector. anyway, not main concern.
i have class :
class : public std::vector<std::vector<double>> { public: a(size_type n, const value_type& val); ... other moethods ... };
what don't understand is, in constructor, why :
matrix::matrix(size_type n, const value_type& val): vector(n, val) { }
work, while if put :
matrix::matrix(size_type n, const value_type& val): std::vector(n, val) { }
it won't compile ? (using gcc-4.8) don't have using namespace std declarations anywhere in code.
why can't put namespace in parent class constructor call?
you can, , should. need specify template parameters of base class:
matrix::matrix(size_type n, const value_type& val): std::vector<std::vector<double>>(n, val) // ^^^^^^^^^^^^^^^^^^^^^
you should not publicly derive std::vector
, know that.
Comments
Post a Comment