循序渐进DLL编程(四)

 在前面的我们进行DLL的编程主要是进行函数的封装,在有时候实现一些功能的时候儿不仅仅是进行函数的封装还是要进行类的封装,在接下来的内容进行类的封装

代码如下:

//point.h
#pragma once
#define DLL_EXPORT __declspec(dllexport)
#define DLL_IMPORT __declspec(dllimport)
#ifdef  DLL_FILE
class DLL_EXPORT  point
#else
class DLL_IMPORT point
#endif
{
public:
    int x;
    int y;
public:
    point();
    point(int xx,int yy);
    void display();
};
//point.cpp
#ifndef DLL_FILE
#define DLL_FILE
#endif

#include"point.h"
#include <stdio.h>

point::point()
{

}


point::point(int xx, int yy)
{
    x=xx;
    y=yy;
}

void point::display()
{
    printf("the value of x is %d  the value of y is %d\n",x,y);
}

//testclassdll

//testclassdll.cpp
#include"testclassdll.h"

#include<stdio.h>
#include"..\\Dllclass\\Point.h"

#pragma comment(lib,"..\\debug\\DLLClass.lib");
int main()
{
  point a(2,1);
  printf("x is %d y is %d\n",a.x,a.y);
  a.display();


  getchar();
    return 0;
}

其实上述的类的封装和使用也是差不多好好学习~~~

posted on 2013-01-27 17:32  AAAAAApple  阅读(217)  评论(0编辑  收藏  举报

导航