c++多文件编译报错:undefined reference to
除了复制构造函数Point::Point(const Point &p)链接成功以外,其余函数和属性皆报错undefined reference
编译器为C free4.0
//point.h文件
class Point{
int x;
int y;
static int count;
public:
Point(int x,int y);
Point(const Point &p);
~Point();
int getX();
int getY();
void showCount();
};
//Point.cpp文件
#include "point.h"
#include <iostream>
using namespace std;
int Point::count=0;
Point::Point(int x,int y):x(x),y(y){
count++;
}
Point::Point(const Point &p):x(p.x),y(p.y){
count++;
}
Point::~Point(){
count++;
}
int Point::getX(){
return x;
}
int Point::getY(){
return y;
}
void Point::showCount(){
cout<<"Object count="<<count<<endl;
}
//5_10.cpp文件
#include "point.h"
#include <iostream>
using namespace std;
void main(){
Point a(4,5);
a.showCount();
Point b(3,5);
b.showCount();
}