So this is my problem: as the title suggests, I have a Labyrinth class that contains two binary trees made of two different kinds of structs that represent different kinds of rooms. The names are in spanish, so Arbol means tree, Laberinto is the labyrinth class and Sala1 and Sala2 are the room structs (and Llave, in case you wonder, means key, but that's not relevant to my question).
struct Sala1 {
int id;
Llave cr_i;
Llave cr_d;
int fno_fix_i;
int fno_fix_d;
int fno_i;
int fno_d;
};
struct Sala2 {
int id;
Llave cr;
};
class Laberinto
{
private:
Arbol<Sala1> a1;
Arbol<Sala2> a2;
/* functions, public, etc */
So my problem is this next piece of code won't work. In case it's hard to guess, x.raiz() obtains the root of tree x. This is a private function by the way.
void Laberinto::reset_contadores (Arbol<Sala1>& x){
x.raiz().fno_i = x.raiz().fno_fix_i;
x.raiz().fno_d = x.raiz().fno_fix_d;
/* rest of code, which calls the same function on the rest of the tree */
}
edit: The public function that calls it looks like this:
void Laberinto::simular_partida (Cjt_Jugador& c, Resultados& r, int N){
reset_contadores (a1);
/* rest of the function */
}
It's just not copying fno_fix_i to fno_i (nor fno_fix_d to fno_d) (checked by printing on screen). I tried creating an auxiliary Sala1 object inside the function and do the same thing to it, and it worked without a problem.
edit : It also won't change it if I try to do ++x.raiz().fno_i, of course. The thing that weirds me out the most is that I can read this tree and set values for fno_i and fno_d in the reading function without a problem, it just won't let me do it here.
What am I missing here?
Ps. Thanks for going through the trouble of reading code with lots of spanish in it, I hope you can understand. If you need anything more to help me with this (be it translations or more code), I'll be more than glad to post it.