I have a struct containing a vector. For that struct I have implemented a function 'add' which purpose is to validate if the data is valid and adds it to the struct.
Because the self-parameter is not defined. A solution would be to recreate the MemoryData object over-and-over again, but that would also re-initialize the vector and make all the precedent data in the vector vanish.
If not, then you'll need to call it on some specific MemoryData value, like this:
foo.add(cat); // `foo` must be a variable that refers to a `MemoryData`.
If you don't have a MemoryData value in scope, then you will need to get one somehow. You could have the caller of your function pass one in, or you could keep one in a field of a struct, or you could create a new one and store it in a local variable...
Thanks for your reply. I have solved it by initializing MemoryData in my main and passing it on through my program through the parameters (by mutable reference).