Hello. I need an example of how to pass an array of pointers to objects as a parameter to a function or a constructor. It's urgent. Please help me. Thank you.

Recommended Answers

All 3 Replies

Do you know how to pass an array of pointers to int? It's the same thing, just with a different pointer type:

void duh ( int *array[], size_t size );

Do you know how to pass an array of pointers to int? It's the same thing, just with a different pointer type:

void duh ( int *array[], size_t size );

I forgot to mention it's a 2 dimensional array. Sorry. Thanks for your help so far. It's rather enlightening

>I forgot to mention it's a 2 dimensional array.
And I forgot to mention that you can just copy the declaration and be done with it:

#include <cstddef> // For size_t

void duh ( int array[5][10], std::size_t x, std::size_t y );

int main()
{
  int array[5][10];

  duh ( a, 5, 10 );
}

You'd probably rather use a vector than an array. They're easier to work with.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.