I tried overloading the += but it get's me an error :
expression must have integral or unscoped enum type
class Sensor{};
class SensorList{
Sensor ** sensors;
};
void main(){
Sensor s1;
SensorList *list = new SensorList();
list += &s1;
}
This is the overloading of += operator
SensorList* operator+=(Sensor * sens){
SensorList * lista= new SensorList();
Sensor ** temp = new Sensor*[this->noElem];
for (int i = 0; i < this->noElem; i++)
temp[i] = this->senzori[i];
delete[] this->senzori;
this->senzori = new Sensor*[this->noElem + 1];
for (int i = 0; i < this->noElem; i++)
this->senzori[i] = temp[i];
this->senzori[this->noElem] = sens;
this->noElem += 1;
lista = this;
return lista;
}
How should I do it? I have to overload the new operator?