-
global classes
Hello,
I need to make a class that I can access by different functions to put in and retreive data from. I've created a global class. I basically want to have two arrays that most of the functions in the programm can access. One would put data in there the other printf it, or something like it. Can I do tha twithout passing the arrays to every function?
Here's the code:
Head file class deffinition:
Code:
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <malloc.h>
# include "stdafx.h"
#include <vector>
class gBAFParmList //Fixed/Selectable Analog Data
{
public:
std::vector < CString > vectBP;
std::vector <CString> vectParmSelected;
};
one of the functions that uses the class:
Code:
void CInitialGUIDlg::OnButton3()
{
// Make Victor
int i=0,j;
FILE *out;
out = fopen("308A.txt", "w"); // Open a file for writing
gBAFParmList PList;
fprintf(out, "\n\n>%s<\n\n", PList.vectBP[i]);
}
-
I think I got it. Just globally creating an instance of that class seemed to work. I wasn't sure if I could do that. If there is anything wrong with this or a better way to do, let me know please.
Thanks,
AS.
-
Depending on the design, another possible soluton is static member variable.
Kuphryn