Never pass an array. This is frowned up in C++ as it's very slow. Pass pointers instead- or use Vectors somehow to pass a pointer instead.
I would make an array, then declare a pointer to the array.
After this, much is highly dependent on if your program is in different files - i.e. different classes, or it's all in one big file.
If your program is in different files, then the definition of the array in the header file is to be included in the other source file: #include "ClassArray.h" somehow.
If your program is all in one file, then the #include is obviously not necessary.
example of Microsoft CArray declaration and using it in parameters:
in the .h file, the definition in a CEnum class:
CArray<CTgA::TRGTAPP, CTgA::TRGTAPP&> a_tga;
where CTgA is a (different) class, and TRGTAPP is a structure (top name) defined in said class in the Public: section.
1 2 3 4 5 6 7 8
|
struct TRGTAPP
{
HWND a_HWND;
CWnd *p_CWndWin;
CString a_Name;
.
.
.
|
a function prototype in a .h file passing the pointer to the array:
void fn_BuildArray(CWnd* c_obj, CArray<CTgA::TRGTAPP, CTgA::TRGTAPP&>& a_tga);
The call to the function in a .cpp file passing the CArray name:
this->fn_BuildArray(p_CWnd_lcl, CEnum::a_tga);
The actual function in a .cpp file:
void CEnum::fn_BuildArray(CWnd *p_CWnd, CArray<CTgA::TRGTAPP, CTgA::TRGTAPP&>& a_tga)
Because CArray in MFC is template-based, just passing 'the name' is not really passing the name, but passing a pointer instead.
hth