std :: queue初始化为NULL

Ane*_*nan 2 c++ queue initialization

是否可以初始化一个C++ std::queueNULL像其他变量的值?

像这样:

HANDLE variable = NULL; 

class Test
{
}
Run Code Online (Sandbox Code Playgroud)

std::queue<Test*> testQueue = NULL;
Run Code Online (Sandbox Code Playgroud)

要么

testQueue.empty();
Run Code Online (Sandbox Code Playgroud)

或类似的东西?

Naw*_*waz 7

如果你这样写:

std::queue<Test*> testQueue; //it is default initialized
Run Code Online (Sandbox Code Playgroud)

那就够了; 无需使用指针并使用NULL初始化它.

此外,您可以这样做:

if ( testQueue.empty()) 
{
    //testQueue is empty
}
Run Code Online (Sandbox Code Playgroud)