views:

46

answers:

2

I have code similar to this in c++. It aborts when i try to run it. Would this type of code work ?

In the main function :

type* a = something
type* b = something    
func1(a,b);

func1 declaration:

void func1(type* &a, type* &b){
  func2(a,b);
  // do something
}

func2 is as follows

void func2(type* &a, type* &b){
  // do something
}

Will these function calls work the way it should. I should have a and b modified because they are passed by reference.

Thanks

A: 

Yes, it should if you modify 'a or 'b in 'func1 or 'func2.

Gabriel Cuvillier
A: 

Yes, the global variables a and b can be changed by either of these functions, in addition to the contents of whatever they're pointing at.

dash-tom-bang