I have problem with pointers. My classes:
Zbior{
Czasteczka* tablicaCzasteczek; //it will be a pointer to dynamic array
Zbior();
}
Czasteczka{
Czasteczka();
Czasteczka(int x, int y);
}
Constructor of Zbior:
Zbior::Zbior()
{
this->tablicaCzasteczek = new Czasteczka[n];
for( int i=0 ; i<n ; i++ )
{
this->tablicaCzasteczek[i] = NULL; <-- here is 1st error
}
this->tablicaCzasteczek[0] = new Czasteczka(X, Y); <-- 2nd error
this->tablicaCzasteczek[1] = new Czasteczka(X, Y+1); <-- same error as above
}
Above code has to create dynamic array and add first and second object to this array.
Errors:
1.) Error 4 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
2.) Error 6 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Czasteczka *' (or there is no acceptable conversion) Thank for all help! :)
Czasteczkais not a pointer. What is assigning null or the result ofnewto one supposed to do?NULLto an instance ofCzasteczka??std::vector<Czasteczka> tablicaCzasteczek;.ndefault constructedCzasteczka!