C++/C++

Advertisement


Question
I wan to pass 2d array as function's argument. i do not want otmake use of pointer so in whiach way i can pass 2D array as functon's argument

Answer
If you want to do it the C way, there is no escaping the pointers. In C++ you're expected to use pointers more for polymorphism than not. One way of using 2D array in C++ could be using boost multi-dimensional array library: see http://www.boost.org/libs/multi_array/doc/user.html Especially see http://www.boost.org/libs/multi_array/doc/user.html#sec_related

If you find this complicated, remember that you have to learn more of C++. Till then, I'd advise you to go back to using pointers. It might not be that ugly: see for example http://irc.essex.ac.uk/www.iota-six.co.uk/c/f2_multidimensional_arrays.asp

Hope this helps!

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Amit Kumar

Expertise

I can answer Cplusplus language and library questions, including STL, ACE, Boost. I have a good background in Mathematics.

Experience

Programming in CPP for about 8 years. Industry experience of 4 years.

Education/Credentials
Bachelors and Masters in Computer Science from Indian Institute of Technology Delhi.

©2016 About.com. All rights reserved.