龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC++动态链接库(DLL)编程深入浅出(二)[组图](10)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
4.7 DLL导出类 DLL中定义的类可以在应用工程中使用。 下面的例子里,我们在DLL中定义了point和circle两个类,并在应用工程中引用了它们(单击此处下载本工

4.7 DLL导出类

  DLL中定义的类可以在应用工程中使用。

  下面的例子里,我们在DLL中定义了point和circle两个类,并在应用工程中引用了它们(单击此处下载本工程附件)。

//文件名:point.h,point类的声明

#ifndef POINT_H

#define POINT_H

#ifdef DLL_FILE

class _declspec(dllexport) point //导出类point

#else

class _declspec(dllimport) point //导入类point

#endif

{

public:

float y;

float x;

point();

point(float x_coordinate, float y_coordinate);

};

#endif


//文件名:point.cpp,point类的实现

#ifndef DLL_FILE

#define DLL_FILE

#endif

#include "point.h"

//类point的缺省构造函数

point::point()

{

x = 0.0;

y = 0.0;

}

精彩图集

赞助商链接