I am new in programming and my problem is probably notorious but still is a problem.
I want build class which can produce object which contain two dimensional dynamic array and member function which fill that array.
Question is where I should to create the array, in function or in constructor.
Cod of array is:
int sizeP, stupaca;
char **polje; //dinamicka alokacija polja s pozivacem na pokazivac
polje = new char*[sizeP];
for (int i = 0; i < sizeP; i++)
{
polje[i] = new char[stupaca + 1];
polje[i][0] = stupaca;
for (int j = 1; j <= stupaca; j++)
polje[i][j] = i + 1 + j / 100.;
}
2. question: do I need copy constructor? Probably yes, but I don’t know create it.
3.Can I delete the array in destructor with following cod:
for (int i = 0; i < sizeP; i++)
delete [] polje[i];
delete [] polje;
Thenx