Topic: Question about passing Functions' parameters ....


Author: tchang@aisun4.ai.uga.edu (Tony Chang [MS AI])
Date: 16 Feb 1994 01:48:37 GMT
Raw View
I have a question regarding passing function parameters, and variables.

I am using BC++ 3.1 and the program is running under Win 3.1, basically it
has several files -- one main program, and several other files.

Okay, now in my main program (MAIN_PRAOGRAM.CPP), I have:

struct {
 mytype *pop1, *pop2; // dynmaic arrays
 ....
 .... etc.
 } myData;

// global variables
myData *globalData;

...
...

(in one of my menu function, i do:)

TMainWindow::Action(...) {

globalData = new myData;
// set some default values
globalData->x = ....
globalData->y = ....
globalData->pop1 = new mytype huge[1000];
globalData->pop2 = new mytype huge[1000]; //huge is used coz' in my application
        this array is > 64K


FunctionCall_1(globalData);
FunctionCall_2(globalData);
FunctionCall_3(globalData);
}

In the other files I have:

OTHERS_1.CPP

void FunctionCall_1(myData *gData) {

// here I changed the values of some variables inside the structure
gData->pop1 = .......
gData->pop2 = ......

FunctionCall_2(gData);

...

}

I again chaged the values of some variables inside the big structure.

The problem is the variables I changed inside the FunctionCall_*s does
not really there -- eg. if I changed something in FunctionCall_1, and
it won't be there in FunctionCall_2, .. etc.

Did I do anything wrong?