Passing a variable by reference through multiple functions

Can someone tell me what is wrong with this code? I'm getting a run time memory allocation error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void function_A(Class_A& class_a)
{
     function_B(class_a);
     return;
}

void function_B(Class_A& class_a)
{
     //do something with class_a
     return;
}

Class Class_A
{
    //stuff
}

Class_A class_a;

Function_A(class_a);


To be more specific, even though I'm passing classa by reference, I'm not altering any of its member variables, I'm only calling several member functions contained in classa.

Thanks!
There is not nearly enough context to make an educated guess.

If you're not altering or should not alter an object, pass it by value or const reference.
Hm, ok. Didn't know if this practice of passing by reference through multiple functions was dangerous or not and errors like this were common. If there's nothing that stands out as being wrong then maybe it's something else in the code.

Thanks.
Topic archived. No new replies allowed.