作者XDucka (Duck)
看板EE_DSnP
标题[问题] undefined reference
时间Mon Dec 17 14:50:28 2012
请问一下为什麽我在
class CirGate
{
public:
CirGate(unsigned g):_ref(_gRef),_gateId(g){}
virtual ~CirGate() {}
...
static unsigned _gRef;
static void gpp(){++_gRef;}
private:
protected:
unsigned _ref;
...
};
class AigGate : public CirGate{
public:
AigGate(unsigned g):CirGate(g),_fanout(0){
_ref=_gRef; ...}
private:
...
};
compile的时候一直出现呢 Q_Q
/home/sillyduck/Ubuntu One/DSnP/hw6/src/cir/cirGate.h:27: undefined reference
to `CirGate::_gRef'
../../lib/libcir.a(cirMgr.o): In function `AigGate':
/home/sillyduck/Ubuntu One/DSnP/hw6/src/cir/cirGate.h:59: undefined reference
to `CirGate::_gRef'
我把code全部复制到新的123.cpp再compile就可以过 =.=|||
顺便问一下 cirp -fl 的顺序不太一样这OK吗
ref的顺序是用dfs的顺序还是照大小排序的顺序阿?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.25.107
1F:推 ypf791:检查一下cirMgr.cpp有没有#include "CirGate.h" 12/17 15:38
2F:推 ypf791:抱歉 是cirMgr.h可能没有#include "CirGate.h" 12/17 15:40
3F:→ ypf791:另外 我觉的_gRef可以定成protected.... 12/17 15:41
4F:→ XDucka:有 Orz 12/17 15:46
已解决Orz 原来static data member的初始化一定要在不同的档案里面
我在.h里面初始化就GG=.=
※ 编辑: XDucka 来自: 140.112.25.107 (12/17 15:59)
※ 编辑: XDucka 来自: 114.25.231.170 (12/17 22:57)
※ 编辑: XDucka 来自: 114.25.231.170 (12/17 23:15)