Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std::queue initialization with NULL

Is it possible to initialize a C++ std::queue with a NULL value like other variables?

Like this:

HANDLE variable = NULL; 

class Test
{
}

i.e.

std::queue<Test*> testQueue = NULL;

or

testQueue.empty();

or something like that?

like image 769
Aneesh Narayanan Avatar asked May 14 '26 20:05

Aneesh Narayanan


1 Answers

If you write this:

std::queue<Test*> testQueue; //it is default initialized

then that is enough; no need to make it pointer and initialized it with NULL.

Also, you can do this:

if ( testQueue.empty()) 
{
    //testQueue is empty
}
like image 90
Nawaz Avatar answered May 17 '26 08:05

Nawaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!