Here is a function similar to the one I’ve defined:
void Function( BYTE *data );
What I would like to do is something like this:
Function( new BYTE { 0x00, 0x00 } );
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot use the array initialiser syntax with dynamically allocated arrays using
new. You could do something like this:But why are you using dynamically allocated memory here? Is the array held onto outside of the scope of the current function? If not, you can use an array allocated on the stack:
In C++, a preferred method is to use the STL class
std::vectorwhich acts like a dynamically allocated (but type safe) array: