Can someone Explain this code to me?

Never mind, I'll try to figure it out on my own.
Last edited on
> #include <cstdlib> //Why is this used?
you need to declare functions before use them. That header has the declarations of `rand()' `srand()' and `system()'

> enum movDir { UP, DOWN, LEFT, RIGHT }; //What is this? Is it a function?
an enum.

> tile() : val( 0 ), blocked( false ) {}
definning a constructor.
after the `:' is the initialization list.
It initializes the member variables.

1
2
    {string    //What is this string doing here? 
        system( "cls" ); //What does this do???? 

It defines an std::string called `system', and with "cls" as value.
It does not call the `system()' function. May be an error, as the string is never used.


> return board[x][y].val == v; //why return an unsigned int when it's bool ???
it is returning a bool, ¿don't you see the `==' sign?
Topic archived. No new replies allowed.