#include<vector>
using namespace std;
struct x{
vector<int> y;
};
void magic(struct x& d)
{
d.y[0] = 5;
}
int main() {
struct x d;
d.y = {1,2,3};
struct x* z = &d;
magic(*z);
cout<<z->y[0];
return 0;
}
Is this code valid and how? Can we pass *z to a function which requires c++ reference.