无法打开包括文件咋回事
问题如下怎么解决呢我是在VS2008上编译的 << ..... \point.cpp(26) : fatal error C1083: 无法打开包括文件:“point.h”: No such file or directory>>程序代码:
#include "stdafx.h" //point.h #include "cmath" #include "iostream" using namespace std; class point { private: double x,y; public: point(double=0,double=0); double Getx(); double Gety(); void Setxy(double,double); ~point(); }; const int num=10; void Set(point *); void Display(point *); double Lenth(point *); //point.cpp #include "point.h" //定义类的成员函数 point::point(double a,double b) {x=a,y=b;} double point::Getx() {return x;} double::point::Gety() {return y;} void point::Setxy(double a,double b) {x=a;y=b;} point::~point() {cout<<"delete it:"<<x<<","<<y<<endl;} // #include "point.h" int _tmain(int argc, _TCHAR* argv[]) { point *p=new point[10]; if(p==NULL) { cout<<"地址申请失败,结束程序运行。\n"; return 0; } Set(p); cout<<"内存块的数据如下:"<<endl; Display(p); cout<<" 组成的折线长度为:"<<endl; cout<<Lenth(p)<<endl; delete []p; return 0; } //内存快赋值函数 void Set(point *p) { double a,b; for(int i=0;i<num;i++) { cout<<"Input第"<<i+1<<"个对象的两个数据成员的值"; cin>>a>>b; (p+i)->Setxy(a,b); } } //显示内存快的值的函数 void Display(point *p) { for(int i=0;i<num;i++) { cout<<(p+i)->Getx()<<","<<(p+i)->Gety()<<endl; } } //计算折现长度函数 double Lenth(point *p) { double sum(0.0),a1,b1,a2,b2; a1=p->Getx(); b1=p->Gety(); for(int i=1;i<10;i++) { a2=(p+i)->Getx(); b2=(p+i)->Gety(); sum=sum+sqrt((a1-a2)*(a1-b2)+(b1-b2)*(b1-b2)); a1=a2; b1=b2; } return sum; }
[ 本帖最后由 tonlin 于 2010-4-5 01:25 编辑 ]