I have a template class so idea of this template
class
is that I want to create vector object of type same as my template class abc
. Can I pass int or char as T
and use something like following
vector<abc<int>> g1;// <<-------how to do this correctly?
g1.push_back({ //<----- looks wrong
{{1,1,1},{2,2,2},{3,3,3}} //<----- this is obvious wrong
})
this is my template class
template <typename T>
class abc: /*drived from what???*/{
private:
T *px=x;
T *py=y;
T *pz=z;
public:
//these members must be included
T x[10];
T y[10];
T z[10];
abc(const T _px[],T _py[],T _pz[]):x{{10}},y{{10}},z{{10}}
{
}
int writeto_HW()
{
//member write to ...x,y,z to... and other work
}
};
int main()
{
vector<abc<int>> g1;// <<-------how to do this correctly?
g1.push_back({ //<----- looks wrong
{{1,1,1},{2,2,2},{3,3,3}} //<----- this is obvious wrong
})
g1.push_back({{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},// <----wrong
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
});
}
is it possible? if yes then how to achieve this
I don't need any fancy push_back
function from vector I just like to have access to inside of push_back
code I will do some business validation on class abc
members x[],y[],z[]
to stl vector's push_back
. so I need just structure what if its possible.
thanks for help