C++头文件与CPP文件所包含的声明有什么区别,为什么这个小程序头文件出问题了
//Point.h#ifndef Point.h
#define Point.h
class Point{
double x,y;
public:
Point(double a=0,double b=0):x(a),y(b){}
double yuandian()const;
double liangdian(const Point& obj)const;
int getx()const;
int gety()const;
void setxy(double a,double b);
void move(double a,double b);
};
#endif
//Point.cpp
#include "Point.h"
#include<math.h>
using namespace std;
void Point::yuandian()const
{
return sqrt(x*x+y*y);
}
void Point::liangdian(const Point& obj)const
{
return sqrt(((x-obj.x)*(x-obj.x)+((y-obj.y)*(y-obj.y));
}
int Point::getx()const
{
return x;
}
int Point::gety()const
{
return y;
}
void Point::setxy(double a,double b)
{
x=a;
y=b;
}
void Point::move(double a,double b)
{
x=a;
y=b;
}
//main
#include <cstdlib>
#include<math.h>
#include <iostream>
#include "Point.h"
using namespace std;
int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;
}
[ 本帖最后由 剑飘香 于 2011-12-10 23:15 编辑 ]