I have a function which gets ‘unsigned int *& argument
The parameter I want to transfer in my code is located in the std::vector<unsigned int> data
So,what I do is : I transfer the following parameter &data[0]
But get the compilation error:
unsigned int *' to 'unsigned int *&
What can be a work around?
Thanks,
&data[0]is an rvalue and cannot be bound to non-const reference.You can make it work this way:
But possibly it’s better to just change the signature of your function to
There is a sense of passing a reference to a pointer in case you want to make a pointer point somewhere else. But I don’t see a reason to do so in your case