编译一直通不过...
#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