I have a class called WeigglhBridge which has one of this method named removeTruck(int).
The class I mentioned above has an account object named Truck record[] which is an array of objects consisting of various trucks.
Now, getting to the main question, the removeTruck(int) method must receive an index as input parameter and remove an existing truck from the list, which is basically "record []".
It involves no pointers. It's just composition.
Please help me, I'm preparing for my exam.
, so I think the error is in line record[index] = NULL;.
However it seems wrong even if the compiler hadn't given you an error, so delete that line.
And, it would be better and simpler to use std::vector instead of an array:
@Fcantoro, I included those headers what exactly do I write in "<my class>"?
I tried writing the WeighBridge class because it is the one that " Truck record[MAX]; as a private data member.
In the body of the method, I did as you coded but it underlines record as an error since is an object of type Truck.
This is the message:
Truck WeighBridge::record[40]
Error: expression must have class type
AFAIK, myclass in your case is Truck.
I suggested you to use vector instead of array, because it is much easier to use, especially in tasks like removing an element.
But, we can't imagine your code.
You should post a minimal compilable code, so we will able to help you.