I am currently doing a little project, and I want to add an element to a pointer of structures, and a function that does it is in struct. Can i use this
to do it?
Department* add_dep()
{
Department* temp;
temp = new Department[deps_count];
for (int i = 0; i < deps_count; i++)
{
temp[i] = this[i];
}
delete[] this;
this = new Department[deps_count];
}
This code gives me an error assignment to this (anachronism)
, and I see why, but I don't see how can I fix this without returning temp
.
How do I do it then?