the fallowing code tells me that o.days and days from constructor can’t be solved, has anyone an idea why?
template <class T> struct Array{
int days;
T * M;
};
contructor of the class:
void constr(Array<Expe> &o){
o=new Array;
o->days = days;
o->M = new Array[o->days];
}
EDIT (Luchian Grigore):
template <class T> struct Array{
int days;
T * M;
Array( int size ) : days(size), M(new int[size])
{
}
~Array()
{
delete[] M;
}
};
when i try to init an array in main like this:
int main(){
//Main function of the program. no pre/ post condition.
Array <Expe> A;
error:
enter code here..\M.cpp:18:15: error: no matching function for call to ‘Array::Array()’
Array<Expe> &ois a reference to anArray<Expe>object, not a pointer. If you must re-initialize it, the syntax is.and you access the members via
.:EDIT:
I remember the same code from yesterday. Why are you agains using proper constructors?