[C++]error C4150: deletion of pointer to incomplete type ; no destructor called

error C4150: deletion of pointer to incomplete type 'XXXXX'; no destructor called

问题原因可能是下面情况之一:

1,成员变量所在的头文件没有引用;

2,A类和B类所属同一命名空间,且A有一个类型为B的成员变量,想通过声明class b的方式不在A的头文件中引用B的头文件,但是却把声明放在了命名空间外,例如:

class B;

namespace SP

{

class A

{

B* b1;

}

}

正确的方式是将声明放到命名空间内: 

namespace SP

{

class B;

class A

{

B* b1;

}

}

猜你喜欢

转载自aigo.iteye.com/blog/2290000