I'm actually trying to do this in objective c, but I belive the theory probarbly are the same for C++.
Heres an example of what I want to do with a simple, working, example using an integer:
void func2(int *i) {
*i = 2;
}
void func1() {
int i = 1;
func2(&i)
// i now equals 2
}
I want to be able to do this with an objec aswell, but when I try with the example under I get the following warning: "Passing argument from incompatible pointer type".
void func2((NSScanner *)aScanner) {
//aScanner is used and updated here.
}
void func1 {
NSScanner *aScanner = initiate new Scanner-object.
[func2 &aScanner];
// Changes done in func2 to the scanner object also applies here
}
I know I would achieve this with a global variable, but from what I understand it's preferred to avoid them when possible.
So anyone who can help me understand why this doesn't work and how to do it properly?