RigidBody
RigidBody

Reputation: 664

C++ how to write header file prototype for a function that accepts an array of object pointers.

Header file prototype (.hpp) is giving a g++ compiler error - no matching function type in header file. What it the correct way to write the prototype (or function parameter)? I've tried oh so many combinations...

void myClass( Objects (*)[] );

Implementation file function definition (.cpp)

void myClass::myFunction( Objects *ptr2object_Array ) {

  /* do stuff */ }

Looked thoroughly for the answer here and elsewhere... Thanks. Aware of the vector lecture, I'm stuck with an array of object pointers.

Upvotes: 0

Views: 395

Answers (1)

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

The function signatures need to match exactly:

void myClass( Objects (*)[] );

void myClass::myFunction( Objects (*ptr2object_Array)[] ) {

  /* do stuff */ 
}

Simple pointers like Objects *ptr2object_Array aren't the same as arrays of pointers.

Upvotes: 3

Related Questions