(*i have to use my array struct, and it has to be dynamical)
I want the Array struct to be filled with Expe class objects. I`m using Templates but somehow my struct header doesn’t recognize the template I have created.
Struct header:
template <class T>;
struct Arr{
int days;
T * M;
};
typedef Arr* Array;
Struct cpp:
void constr(Array &o){
//Construct of 31*1 Matrix
o=new Arr;
o->days = 31;
o->M = new T[o->days];
It should be fine I think, but I get error:
..\ListStruc.cpp:26:13: error: expected type-specifier before 'T'
You have a semicolon between
template<class T>andstruct Arr, which doesn’t belong there. So change it toFurthermore
Arris a template and therefore you can’t typedefArr*toArray, onlyArr<someConcreteType>*.Last template functions must be implemented in the header and, as mentioned you typedef doesn’t work so put
constrin a header and change it to:There might be other problems, but that is what I can see from the question.
Of course there are problems with your code apart from the compilation (violation of the rule of three and lack of exception safety).