当用C++覆盖一个类(使用虚拟析构函数)时,我在继承类上再次将析构函数实现为虚拟,但是我是否需要调用基本析构函数?
如果是这样,我想它就是这样......
MyChildClass::~MyChildClass() // virtual in header
{
// Call to base destructor...
this->MyBaseClass::~MyBaseClass();
// Some destructing specific to MyChildClass
}
Run Code Online (Sandbox Code Playgroud)
我对吗?
编译iPhone项目时遇到以下错误.谁知道我怎么解决它?"ved for oned :: MultiFormatUPCEANReader",引用自:MultiFormatUPCEANReader.o中的__ZTVN4oned23MultiFormatUPCEANReaderE $ non_lazy_ptr ld:未找到符号collect2:ld返回1退出状态
我正在重新学习C++(意思是:温柔地对待我!:).我有一个Node带有抽象方法(step())的超类(),它必须在子类(TestNode)中实现.它编译没有错误,没有任何警告,但链接它导致:
bash-3.2$ g++ -Wall -o ./bin/t1 src/t1.cpp
Undefined symbols for architecture x86_64:
"typeinfo for test::Node", referenced from:
typeinfo for test::TestNode in t1-9f6e93.o
"vtable for test::Node", referenced from:
test::Node::Node() in t1-9f6e93.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
据我所知,我已经定义了"第一个非内联虚拟成员函数"(即TestNode::step()).
我已经仔细阅读错误消息,我读过的博客文章在这里,并期待其他一些SO职位( …