Using a function that looks like:
IntegerSet &insert(int m);
I'm trying to create a function that supports cascading calls that insert values into an object's array.
My function:
IntegerSet &IntegerSet::insert(int m) {
IntegerSet newObj;
for (int i = 0; i < 256; i++) {
newObj.set1[i] = set1[i]; //copy the array into the new object
}
newObj.set1[m] = true;
return newObj;
}
The object being returned is empty, which I suspect has to do with the reference.
Attempting to change it by altering the &
to look like
IntegerSet IntegerSet::&insert(int m)
makes it refuse to compile because it 'expects an identifier'.