471,585 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,585 software developers and data experts.

How to declare function returning array of Integer pointers

How can I declare function returning array of Integer pointers . Please
help !!

Feb 6 '06 #1
2 6975
On 2006-02-06 08:35:43 -0500, "Tany" <ta**********@gmail.com> said:
How can I declare function returning array of Integer pointers . Please
help !!


You can't. You can, however, declare a function returning any of:
A reference to an array
A pointer to an array
A vector
A structure containing an array,
etc.

You could also write a function that takes as a parameter a reference
or pointer to any of the above, and then populates the
referenced/pointed-to object instead of returning the same data.

Another option is to write a function that takes an output iterator as
a parameter. The function could then write to that iterator.

Which of these you should use depends on the actual problem that you're
trying to solve.

--
Clark S. Cox, III
cl*******@gmail.com

Feb 6 '06 #2
As has been pointed out, if you're working with C arrays you need to
be more specific about what you're trying to do in order to get a clear
answer. You don't have to return anything if the array already
exists--just pass it into the function. If the function creates it,
it'll have to allocate it on the heap and return a pointer.
std::vector<int*> would almost always be recommended unless you were
newly trying to learn the language. (After all, this isn't comp.lang.c
;-)

Feb 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

41 posts views Thread by Materialised | last post: by
10 posts views Thread by Barbrawl McBribe | last post: by
5 posts views Thread by Cancerbero | last post: by
26 posts views Thread by cdg | last post: by
6 posts views Thread by M Turo | last post: by
26 posts views Thread by aruna.mysore | last post: by
13 posts views Thread by Sri Harsha Dandibhotla | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.