//point.h
#ifndef POINT_H
#define POINT_H
#ifdef DLL_FILE
class _declspec(dllexport)point
#else
class _declspec(dllimport)point
#endif
{
public:
point(float a=0,float b=0);
void getPoint(float&,float&);
private:
float x;
float y;
};
#endif
//point.cpp
#ifndef DLL_FILE
#define DLL_FILE
#endif
#include"stdafx.h"
#include "point.h"
point::point(float a,float b)
{
x=a;
y=b;
}
void point::getPoint(float &a,float &b)
{
a=x;
b=y;
}
//circle.h
#ifndef CIRCLE_H
#define CIRCLE_H
#include "point.h"
#ifdef DLL_FILE
class _declspec(dllexport)circle
#else
class _declspec(dllimport)circle
#endif
{
public:
circle();
void setCentre(const point&);
void setRadius(const float &);
float getArea();
// ~circle(){};
private:
point centre;
float radius;
};
#endif
//circle.cpp
#ifndef DLL_FILE
#define DLL_FILE
#endif
#include "stdafx.h"
#include "circle.h"
const PI=3.1415926;
circle::circle()
{
centre=point(0,0);
radius=0;
}
float circle::getArea()
{
return PI*radius*radius;
}
void circle::setCentre(const point &p)
{
centre=p;
}
void circle::setRadius(const float &r)
{
radius=r;
}
//主程序
// dllClassCall.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "point.h"
#include "circle.h"
#pragma comment(lib,"dllClassTest.lib");
#include<iostream>
using namespace std;
int main(int argc, char* argv[])
{
point p;
float x,y;
p.getPoint(x,y);
cout<<x<<endl<<y<<endl;
circle c;
/* float r=1;
c.setCentre(p);
c.setRadius(r);
cout<<c.getArea()<<endl;*/
cin.get();
return 0;
}
当主程序中没有circle的对象时,程序正确运行。但是当有circle对象时出现无法定位程序输入点的错误
请高手指点!!!!!!
[此贴子已经被作者于2007-10-28 13:30:51编辑过]