相关疑难解决方法(0)

为什么不能将不完整的类型转换为无效?

为什么以下代码会出现以下错误?

为什么类型需要完整才能投入void

struct Incomplete;
class Class
{
    virtual void foo(Incomplete &incomplete)
    {
        (void) incomplete;
        throw std::logic_error("not implemented");
    }
};
Run Code Online (Sandbox Code Playgroud)

错误:

error C2027: use of undefined type 'Incomplete'  
    see declaration of 'Incomplete'
Run Code Online (Sandbox Code Playgroud)

c++ void incomplete-type

4
推荐指数
1
解决办法
156
查看次数

标签 统计

c++ ×1

incomplete-type ×1

void ×1