c++ - Using object inside constructor -


i creating own vector class inheriting stl one. have problem while creating object.

here class.

using namespace std;  template <class t>  class arithmeticvector : public vector<t>{ public:     vector<t> vector; //maybe should not initalize     arithmeticvector(){};     arithmeticvector(t n) : vector(n){    //something here }; 

in main; calling this;

arithmeticvector<double> v9(5); 

or

arithmeticvector<int> v1(3); 

what want creating v9 vector or v1 vector stl vector type. vector inside newly created object. want object vector @ first.

maybe should use v1 object inside constructor ? help.

if need elementwise operations , math on std::vector, use std::valarray. if not, don't see why subclassing std::vector.

don't inherit form std:: containers, don't have virtual destructor , blow in face if deleted pointer base.

edit if need define operations on std::vector, can defining operators outside of class, , using public interface.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -