Xcode未定义符号~析构函数
Xcode undefined symbols ~ destructor
Undefined symbols for architecture x86_64:
"Matrix::~Matrix()", referenced from:
_main in p1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我得到这个错误时,试图在xcode编译。问题在于头文件中的析构函数声明。如果我把析构函数注释掉,它就会成功构建。
class Matrix {
public:
~Matrix();
};
您还没有定义析构函数。当注释掉它时,析构函数将是隐式声明的析构函数,因此链接器会找到它。你说"……将被定义"。这是否意味着你还没有定义它?
From cppreference.com (http://en.cppreference.com/w/cpp/language/destructor)
如果没有为类类型(struct)提供用户声明的析构函数,类或联合),编译器总是将析构函数声明为类的内联公共成员。
相关文章:
- 什么时候调用组成单元对象的析构函数
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 内联映射初始化的动态atexit析构函数崩溃
- 什么时候调用析构函数
- 优先顺序:智能指针和类析构函数
- C++-明确何时以及如何调用析构函数
- 使用基类指针创建对象时,缺少派生类析构函数
- 在c++中使用向量时,如何调用构造函数和析构函数
- 重载运算符new[]的行为取决于析构函数
- 我需要知道编译器如何在cpp中使用析构函数
- 为什么在使用转换构造函数赋值后调用C++类的析构函数?
- 析构函数调用
- 通过引用传递-为什么要调用这个析构函数
- 仅在 MacOS 上析构函数的未定义符号
- bad_alloc::'标量删除析构函数'(无符号整数)当我尝试创建矢量 470MB 大小时
- C++虚拟析构函数和符号引用错误
- 在我的程序中"无符号"之前的预期主表达式(析构函数和构造函数问题)
- CUDA:__device__和__global__错误:在"无符号"/"void"之前预期的构造函数、析构函数或类型转换"
- Xcode未定义符号~析构函数
- 类析构函数符号出了什么问题?在vc++中