gpt4 book ai didi

c++ - 删除指向不完整类型的指针

转载 作者:行者123 更新时间:2023-11-27 22:42:08 24 4
gpt4 key购买 nike

<分区>

我试着删除我的结构

delete it;

并收到通知,此类型不完整。

Warning: C4150: deletion of pointer to incomplete type 'It'; no destructor called

我必须在头文件中使用前向声明。

好吧,我认为在同一个文件中使用迭代器创建删除函数是正确的方法

void deleteIterator(It* it)
{
delete it;
}

然后从任何地方调用它;

deleteIterator(it)

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