Hi,
I need to count the times my public member function creates new data in a loop. Each time data is read it is saved into a private member varaible. Nothing is overwritten.
// my classType.h
const int ImpliedIndex = 1000;
class classType
{
private:
char privateMember[ImpliedIndex];
char privateMember2[ImpliedIndex];
public:
static void myMemberCounter;
void printMyInformation():
void mySupplier(const char[] );
...
};
//classType.cpp
int globalCounter = 0;
void classType::printMyInformation()
{
...
cout << privateMember << endl;
cout << globalCounter++ << endl;
}
void classType::mySupplier( const char buff[] )
{
strcpy( privateMember, buff );
}
// The main should clear things up a bit.
// main.cpp
int main()
{
while ( !inFile.eof() )
{
for ( int x = 0; x < 20; x++ )
{
// do file I/O here
// save each line of file into an temp array
// supply temp array with a routine defined in myClass
// re-use temp array until we run out of file
}
}
//close file
I need to change my 20 to a variable. Notice that in classType I used globalCounter to retrieve the number of types.
What I wanted to do is, globalCounter = memberCounter;
But I have to re-declare both of these varaibles, and I can't use myClass[ImpliedIndex].memberCounter
with the assignment operator (=) or the binary insertion operator(<<).