gpt4 book ai didi

c++ - std::queue 初始化为 NULL

转载 作者:太空狗 更新时间:2023-10-29 23:33:44 25 4
gpt4 key购买 nike

是否可以像其他变量一样用 NULL 值初始化 C++ std::queue

像这样:

HANDLE variable = NULL; 

class Test
{
}

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

testQueue.empty();

或者类似的东西?

最佳答案

如果你这样写:

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

那就够了;无需将其设为指针并用 NULL 对其进行初始化。

此外,您还可以这样做:

if ( testQueue.empty()) 
{
//testQueue is empty
}

关于c++ - std::queue 初始化为 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10169283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com