Hello,
I have created several objects for my program:
State
County
Municipality
Data Layer
The objects are setup as follows:
The State object has an array of Countie pointers
The County object has an array of Municipalities pointers
The Municipality object has an array of Data Layers pointers
In other words:
<State> has 1 to many <Counties> has one to many <Municipalities> has 1 to many <Data Layers>.
In my program I search a directory structure recursively. The first directory is assigned as a county if the first county element of the State object is null.
However, I seem to have a tough time testing the county arrary for nulls.
I use a function entitled getCurCounty to return a pointer to the current county pointer of the State object in the following fashion:
The getCurCounty() function's code is below:Code://if the county pointer is null if(StateArg->getCurCounty() == 0) { cout << "About to create a county." << endl << endl; getch(); //add a county to the state object StateArg->addCounty(new County(fileStruct.name)); } //end if countyPtr is null
How do I properly test the county arrary of pointers in my state object for nulls? The execution seems to bypass the if statement in the first code segment.Code:County * State::getCurCounty() { return counties[numOfCounties]; } //end State::getCounty



LinkBack URL
About LinkBacks


