Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

methods returning arrays

Status
Not open for further replies.

falled

Programmer
Nov 3, 2006
47
0
0
ES
Yes a Know this should be easy, And I aware you, this is a newbie question XD

I've been searching for internet and nothings seems clear to me

How can I implement methods that returns arrays of floats or ints?

float * method_name();?

and the implemention?

I don't need all the explanation, just point me to the right way and I will get deep in the problem,

Thank you all and sorry for my bad writting!!
 
A better way might be to return a vector<float>
But an array is basically just a pointer to the first element of the array.
Also, don't even try to return a local array, since it'll be popped off the stack as soon as the function returns, then you have a pointer to nowhere.
Code:
float* MyFunc()
{
   float* pArray = new float[40];
   ...
   return pArray;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top