Reputation: 683
i get this error at the constructor of my struct. why do i get it sincei work only with * pointers not **.
Error:
\ListStruc.cpp:26:25: error: cannot convert 'int**' to 'int*' in assignment
struct.h
struct Arr{
int days;
int *M;
};
typedef Arr* Array;
struct.cpp
void constr(Array &o){
//Construct of 1*31 Matrix
o=new Arr;
o->days = days;
o->M = new int*[o->days];
Upvotes: 0
Views: 74
Reputation: 258608
Since M
is an int*
, the correct initialization would be:
o->M = new int[o->days];
Upvotes: 3