struct article {
int uId;
char uName[201];
article(int Id, char* name) { uId = Id;
for(int i=0;name[i]!='\0';i++)
{
uName[i]=name[i];
}
}
};
int main()
{
char Name[201];
int ID;
int N;
cin>>N;
article* articleArr = new article[N]; //error thrown on this line
/*Some code that creates ID and Name*/
articleArr[index] = article(Id, Name);
cout<<articleArr[index].uId<<' '<<articleArr[index].uName<<endl;
}
The problem I have with my code is that I can't dinamically create an array of structs. Compiler throws out an error "no matching function for call to 'article::article()" at the (article* articleArr = new article[N];) line. Before I started implementing dynamic initialization of array of structs it worked fine. I have to use char arrays, not allowed to use strings.