Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random not declared in scope

Tags:

c++

include

I am getting the error:

tester.cpp|20|error: 'rand' was not declared in this scope|

Did I miss to include something here?

void tester::volumeset(bool A_B, int i, int v)
{
    if (A_B == true)
    {
        A_volumn[i] = rand(v+1);
    }else{
        B_volumn[i] = rand(v+1);
    }
}
like image 272
soniccool Avatar asked Nov 26 '12 15:11

soniccool


1 Answers

random is not a standard C++ function; it's a POSIX function, so it's not available on Windows. Use rand instead, or better, the new C++11 randomness library.

like image 74
Fred Foo Avatar answered Sep 20 '22 10:09

Fred Foo