|
//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; |
|