I don't understand this simple function that come directly out of the book: Jumping into C++. It is supposed to be a recursive function.
First this function starts out with an unknown (int height), then it uses the if statement to compare the height to zero. Then (I believe it calling itself ?) and (then subtract 1 from the height ?) Until the height is zero? After this is true... Then it addBrickLayer.
Is my explanation right or wrong?
Why wouldn't you just start a wall from the ground rather then decrease the height? This does not make any sense to me.
One final question. Is (height-1) sent backs to (int height) as the argument?
Code:void buildWall (int height) { if ( height > 0 ) { buildWall( height - 1 ); } addBrickLayer(); }