欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
DLL導出類(lèi) - 時(shí)間的痕跡 - C++博客
DLL導出類(lèi)

  DLL中定義的類(lèi)可以在應用工程中使用。

  下面的例子里,我們在DLL中定義了point和circle兩個(gè)類(lèi),并在應用工程中引用了它們(單擊此處下載本工程附件)。

//文件名:point.h,point類(lèi)的聲明

#ifndef POINT_H

#define POINT_H

#ifdef DLL_FILE

class _declspec(dllexport) point //導出類(lèi)point

#else

class _declspec(dllimport) point //導入類(lèi)point

#endif

{

public:

float y;

float x;

point();

point(float x_coordinate, float y_coordinate);

};

#endif


//文件名:point.cpp,point類(lèi)的實(shí)現

#ifndef DLL_FILE

#define DLL_FILE

#endif

#include "point.h"

//類(lèi)point的缺省構造函數

point::point()

{

x = 0.0;

y = 0.0;

}

//類(lèi)point的構造函數

point::point(float x_coordinate, float y_coordinate)

{

x = x_coordinate;

y = y_coordinate;

}


//文件名:circle.h,circle類(lèi)的聲明

#ifndef CIRCLE_H

#define CIRCLE_H

#include "point.h"

#ifdef DLL_FILE

class _declspec(dllexport)circle //導出類(lèi)circle

#else

class _declspec(dllimport)circle //導入類(lèi)circle

#endif

{

public:

void SetCentre(const point ¢rePoint);

void SetRadius(float r);

float GetGirth();

float GetArea();

circle();

private:

float radius;

point centre;

};

#endif


//文件名:circle.cpp,circle類(lèi)的實(shí)現

#ifndef DLL_FILE

#define DLL_FILE

#endif

#include "circle.h"

#define PI 3.1415926

//circle類(lèi)的構造函數

circle::circle()

{

centre = point(0, 0);

radius = 0;

}

//得到圓的面積

float circle::GetArea()

{

return PI *radius * radius;

}

//得到圓的周長(cháng)

float circle::GetGirth()

{

return 2 *PI * radius;

}

//設置圓心坐標

void circle::SetCentre(const point ¢rePoint)

{

centre = centrePoint;

}

//設置圓的半徑

void circle::SetRadius(float r)

{

radius = r;

}

類(lèi)的引用:

#include "..\circle.h"  //包含類(lèi)聲明頭文件

#pragma comment(lib,"dllTest.lib");


int main(int argc, char *argv[])

{

circle c;

point p(2.0, 2.0);

c.SetCentre(p);

c.SetRadius(1.0);

printf("area:%f girth:%f", c.GetArea(), c.GetGirth());


return 0;

}


  從上述源代碼可以看出,由于在DLL的類(lèi)實(shí)現代碼中定義了宏DLL_FILE,故在DLL的實(shí)現中所包含的類(lèi)聲明實(shí)際上為:

class _declspec(dllexport) point //導出類(lèi)point

{



}


  和

class _declspec(dllexport) circle //導出類(lèi)circle

{



}


  而在應用工程中沒(méi)有定義DLL_FILE,故其包含point.h和circle.h后引入的類(lèi)聲明為:

class _declspec(dllimport) point //導入類(lèi)point

{



}


  和

class _declspec(dllimport) circle //導入類(lèi)circle

{



}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
C++繼承的使用
第二題
面向對象: 理解python類(lèi)的單繼承與多繼承
VC 動(dòng)態(tài)鏈接庫(DLL)編程深入淺出
vc dll 浮點(diǎn)傳遞 與調用約定 問(wèn)題
What Is Pi, and How Did It Originate?
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久