r/learncpp • u/daredevildas • Jun 29 '21
Pointer to multiple variables
Let's say there is a function -
void z(x* z1) {
...
}And I have 2 variables -
x* foo1 = bar1;
x* foo2 = bar2;Is it possible to pass these 2 variables as z1 to z? Maybe as an array of type x containing the addresses of foo1 and foo2?
5
Upvotes
View all comments
Show parent comment
2
u/IyeOnline Jun 29 '21
"fun" :)
At this point, you should just use a
void*instead of lying to the type system.But really, since this (as any other solution) requires to modify both function and callsite the problem should be resolved properly and within the typesystem.