[已解決]
不是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