C++ 常见的 Undefined symbols for architecture *


出现 

Undefined symbols for architecture x86_64:

的原因

1.函数申明了,却未被定义。

2.申明的虚函数未被实现。

NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.

3.使用template <class T> 实现类时。若是将函数声明写在.h文件,实现写在.cpp。则出现Undefined symbols for architecture x86_64。应将申明和实现都放在.h文件

template <class T>
class Heap {
    typedef typename vector<T>::iterator iterator;
private:
    vector<T> container;
    void swim(int i);
    void sink(int i);
};
template <class T>
void Heap<T>::swim(int i) {
    while (i > 1&&container[i]>container[i/2])
    {
        T temp = container[i];
        container[i] = container[i/2];
        container[i/2] = temp;
        i = i/2;
    }
}

 http://www.cnblogs.com/like1/p/6848669.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM