954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ pass 2d array into function

Hi I am getting this error with my code as I try to pass a 2d array into a function :

mymain.cpp:173: error: cannot convert `float (*)[((dimensions - 1) + 1)]' to `float**' for argument `1' to `float objfunc(float**)'])'

The code is as follows:

http://cpp.sourceforge.net/?show=4356

The lines 0030, 173 and 282 are where the problems are,

If anyone could be of any help i woule be extremely gratefull as I have been stuck on it for quite a while now. thanks in advance.

tw0nk
Newbie Poster
1 post since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

When an array name is used, it is usually converted to a pointer to the first element. This only works for the first dimension, so you're actually passing a pointer to an array of size dimensions, not a pointer to a pointer to float.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You