- 论坛徽章:
- 0
|
CNGraph.h
- #ifndef __CNGRAPH_H
- #define __CNGRAPH_H
- class CGraph
- {
- private:
- public:
- void addLink(unsigned short, unsigned short);
- };
- #endif
复制代码
CNGraph.cpp
- #include "CNGraph.h"
- ////////////// class CGraph ////////////
- inline void CGraph::addLink(unsigned short a, unsigned short b)
- {
- }
复制代码
test.cpp
- #include "CNGraph.h"
- int main()
- {
- CGraph g;
- g.addLink(0,1);
- }
复制代码
编译错误:
g++ test.cpp CNGraph.cpp
/tmp/ccoZkP9d.o(.text+0x1c): In function `main':
: undefined reference to `CGraph::addLink(unsigned short, unsigned short)'
collect2: ld returned 1 exit status
但如果
CNGraph.cpp
- #include "CNGraph.h"
- ////////////// class CGraph ////////////
- void CGraph::addLink(unsigned short a, unsigned short b)
- {
- }
复制代码
就可以。为什么呢?找了些资料,没发现。多谢 |
|