亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

編譯一直通不過...

#include?<iostream>
#include?"Coordinate.h"
using?namespace?std;
class?Line
{
public:
Line();
~Line();
private:
Coordinate?*m_coorA;
Coordinate?*m_coorB;
};


Line::Line()
{
m_coorA?=?new?Coordinate(1,2);
m_coorB?=?new?Coordinate(3,4);
}??
Line::~Line()
{
}
int?main(void)
{
Line?*p;
p?=?new?Line();
delete?p;
p=NULL;
}

Coordinate那2個文件是一樣的,可以直接通過編譯的.但是,在編譯Line.cpp的時候報錯.

系統1:

Undefined symbols for architecture x86_64:

"Coordinate::Coordinate(int, int)", referenced from:

? ? ? Line::Line() in Line-6b7c1a.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

[Finished in 0.4s with exit code 1]


系統2:

/tmp/cc2zKqau.o: In function `Line::Line()':

Line.cpp:(.text+0x2a): undefined reference to `Coordinate::Coordinate(int, int)'

Line.cpp:(.text+0x50): undefined reference to `Coordinate::Coordinate(int, int)'

collect2: error: ld returned 1 exit status




正在回答

1 回答

原來是編譯器沒配置好.只能編譯單文件.忽略.

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
C++遠征之封裝篇(下)
  • 參與學習       70902    人
  • 解答問題       534    個

封裝--面向對象三大特征之一,通過案例讓C++所學知識融會貫通

進入課程

編譯一直通不過...

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號