Assume we have these declarations:
int** a;
int b[x][y];
Can I implement a function
foo f(bar c) {}
that lets me
f(a);
f(b);
without needing to overload it?
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.
Sure, just use
void*🙂And to answer your question, no. A multidimentional array is not the same as a pointer to a pointer. The reason is the indexing scheme.
int b [2][2]is a continuous memory block of 4 integers. Indexing into it is equivalent to the following:The second dimension is part of the type defintion! The compiler knows that it only needs one dereference due to the memory layout of the array.
Meanwhile, for
int** athe indexing is done like this: