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

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -