I am fairly new to C++. I work as an intern and I need to pass a pointer to a function. Can someone please help.

U8 System::check()
{
  Array drives = Array::update(system);    
  ......
  ......
  check2(drives);
  ........
}

U8 System::check2(Array drives)
{
  Array bad_drives = Array::drives.filter(&new_drives);
}

If I were to put everything in a one function, it all works. Therefore, there is something wrong with the way I pass parameters into the function. I do have a .h file.

Are you allowed to change the signature of the check2 function?

how to use typedef with a function pointer:

typedef void (*FuncType)(void);
...
...
FuncType pointerToMyFunc = foo;

When you call check2(drives), the formal parameter is an Array. That means that drives is copied and what check2 sees is a copy of it. Is that what you intend? If not, the parameter should probably be Array&. It's hard to say more without seeing all the code.

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.