Why doesn’t this code work at making a 2D array pointers in c++? The compiler complains about the second line not being a modifiable l-value.
int* g[2][2];
g[0] = new (int*)[2];
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.
The type of
g[0]isint* [2], i.e. it’s an array. You cannot assign to an array.It’s not clear what you’re trying to achieve, so I can’t offer a solution. If you clarify your question, I may be able to do better.