简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM