zoukankan      html  css  js  c++  java
  • 循序渐进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;
    }

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

  • 相关阅读:
    01_计算机基础
    09_哈希表
    08_查找算法
    Swagger使用
    Thymeleaf代码实例
    Spring boot代码实例
    Spring mvc代码实例
    Hibernate代码实例
    Mysql JDBC代码实例
    Mybatis代码实例
  • 原文地址:https://www.cnblogs.com/OneDream/p/2878902.html
Copyright © 2011-2022 走看看