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