std :: queue初始化为NULL [英] std::queue initialization with NULL
本文介绍了std :: queue初始化为NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以像其他变量一样使用 NULL
值初始化C ++ std :: queue
p>
像这样:
HANDLE variable = NULL;
class Test
{
}
ie
std :: queue< Test *> testQueue = NULL;
或
testQueue.empty();
或类似的东西?
解决方案
如果你这样写:
std :: queue< Test *> testQueue; //它是默认初始化的
此外,你可以这样做:
if(testQueue.empty())
{
// testQueue is empty
}
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?
解决方案
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
}
这篇关于std :: queue初始化为NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文