dynamic allocation problem in function

if I want to call a function manipulateMatrix(Image * im, int n);
Image is a class, which one is a better function? Can you classify the situation to use either of them? Thanks a lot!
1. manipulateMatrix(Image ** im_p, int n);
//assume many return objects, so cannot use return value
// allocate the class in the function, pass the pointer of parameter back
2. manipulateMatrix(Image * im, int n);
// allocate the object in main(), then call the function with parameter of object.
I'm not sure I fully understand the situation. Couldn't you use a reference?
I am not understanding what you want either,

An image is a block of data, accessing either way would work, but would have different syntax for each. The code that came out of the compiler would generally be the same.
...If I'm understanding you right, then, I would do the second. It seems odd to me to have a function return a dynamically allocated object that the user has to be responsible for freeing. In the second case, the user both new's and delete's the object.
Topic archived. No new replies allowed.