作者mhnp1580 (小路尼)
看板EE_DSnP
標題[問題] Undefined reference to 'vtable
時間Mon Dec 17 23:00:56 2012
[已解決]
不是constructor的問題,
是void printGate() const沒有define
要多加
{}
感謝幫我解惑的同學!!!
======================================================================
不好意思想了很久都無解 =____=
我在make的時候出現了以下的error message:
../../lib/libcir.a(cirMgr.o): In function `PI::PI(unsigned int, unsigned
int)':
/home/weining/Documents/hw6/src/cir/cirGate.h:60: undefined reference to
`vtable for PI'
collect2: error: ld returned 1 exit status
以下是程式碼的部分
======================================================================
cirGate.h
class CirGate
{
public:
CirGate(unsigned i = 0, unsigned l = 0, CirGate* fi1 = 0, bool s1 = 0,
CirGate* fi2 = 0, bool s2 = 0) : _id(i), _line(l)
{
_fanin[0] = fi1;
_faninSign[0] = s1;
_fanin[1] = fi2;
_fanoutSign[1] = s2;
}
...
protected:
unsigned _id;
unsigned _line;
CirGate* _fanin[2];
bool _faninSign[2];
GateList _fanout;
vector<bool> _fanoutSign;
}
class PI: public CirGate
{
public:
PI(unsigned i = 0, unsigned l = 0) : CirGate(i, l) {}
...
};
然後在
cirMgr.cpp的readCircuit()裡:
CirGate* gPtr = new PI(id, lineNo);
=================================================================
如果我沒有new PI就不會有以上的error message
但又不能不new PI =____=
拜託大家幫忙了感謝QQ
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.25.106
※ 編輯: mhnp1580 來自: 140.112.25.106 (12/17 23:38)
1F:推 peter0902:搜尋 vtable -> 12/20 12/17 12/17 每年HW6必經之路! 12/18 00:39
2F:→ ypf791:code 是不是不要這樣 po 比較好.... 12/18 01:42