Thread: What are the various dll, and how skillfully to write classes within them, well writt

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    112

    What are the various dll, and how skillfully to write classes within them, well writt

    What are the various dll, and how skillfully to write classes within them, well written, saving and using.

    Hello dear!

    I am very interested, I want so many dll in various ways, what would be the skill in this.

    So I compiled the file and compiled the dll for it too.

    The file was going well, the dll compiled without errors, but it does not work.

    I still can not see any class or functions! Every time failure set in wait for the frustrated.

    Understanding is looking for, what's the failure, and how especially to write classes using various methods?

    I will even lay out the full archive with the contents.


    Code:
    #include <cstring>
    
    class __declspec(dllexport) Mat {
    private:
      int x;
      int y;
      int rezultat;
    public:
      Mat() : x(0), y(0), rezultat(0) {}
      Mat(int _x, int _y ): x(_x), y(_y), rezultat(0) {}
      int plus(){ rezultat = x+y; return rezultat;}
      int minus(){ rezultat = x-y; return rezultat;}
      int mnozhyty(){ rezultat = x*y; return rezultat;}
      int dilyty(){ if(y!=0) rezultat = x/y; else rezultat = 0; return rezultat;}
      void zadaj(int _x, int _y){ x=_x; y=_y;}
    };
    
    
    
    __declspec(dllexport) Mat Mat_vydaj_nazovni_functija(int w, int h)
    {
         Mat m(w, h);
         return m;
    }
    
    __declspec(dllexport) int rezultat_vydaj_nazovni_functija(int w, int h, char vybor[250])
    {
         Mat q(w, h);
         if(strcmp(vybor,"minus"))
        {
            return q.minus();
        }
        else if(strcmp(vybor,"plus"))
        {
            return q.plus();
        }
        else if(strcmp(vybor,"mnozhyty"))
        {
            return q.mnozhyty();
        }
        else if(strcmp(vybor,"dilyty")==0)
        {
            return q.dilyty();
        }
        else
        {
            return 0;
        }
    
    }

    Code:
    #include <windows.h>
    #include <stdio.h>
    #include <iostream>
    //#include "Mat.hpp"
    
    
    int main ()
    {
         HMODULE deskriptor_modula = LoadLibrary ("Mat_dll.dll");
         FARPROC adres_funktsii_plus = GetProcAddress (deskriptor_modula, "plus");
    
         char mainchar [255]  = "MAIN TSE POCHATOK";
         class __declspec(dllimport) Mat {};
         Mat mat1;
    
    
        typedef Mat (*Mat_vydaj_nazovni_functija)(int, int);
        Mat_vydaj_nazovni_functija pMat_vydaj_nazovni_functija = (Mat_vydaj_nazovni_functija)GetProcAddress(deskriptor_modula, "Mat_vydaj_nazovni_functija");
        if (pMat_vydaj_nazovni_functija != NULL)
        {
            mat1 = (*pMat_vydaj_nazovni_functija) (70, 10);
           //int min mat1;
           int *pmat = (int*) &mat1;
            std::cout << pmat << std::endl;
        }
    
        typedef int (*rezultat_vydaj_nazovni_functija)(int, int, char[250]);
        rezultat_vydaj_nazovni_functija prezultat_vydaj_nazovni_functija = (rezultat_vydaj_nazovni_functija)GetProcAddress(deskriptor_modula, "rezultat_vydaj_nazovni_functija");
        if (prezultat_vydaj_nazovni_functija != NULL)
        {
            char vybir[250][4] = { "minus", "plus", "mnozhyty", "dilyty" };
            int i=0;
            std::cout << vybir[250][0] << " " << "vvedy" << " 0" << std::endl;
             std::cout << vybir[250][1] << " " << "vvedy" << " 1" << std::endl;
             std::cout << vybir[250][2] << " " << "vvedy" << " 2" << std::endl;
             std::cout << vybir[250][3] << " " << "vvedy" << " 3" << std::endl;
            std::cin >> i;
    
            int rezultat = (*prezultat_vydaj_nazovni_functija) (70, 10, vybir[250][i]);
           //int min mat1;
           std::cout << rezultat << std::endl;
        }
        //
        FreeLibrary(deskriptor_modula);
    
         //int mysum = mat1.plus();
         int *pmat = (int*) &mat1;
         std::cout << pmat << std::endl;
         std::cout << mainchar << std::endl;
         std::cin >> mainchar;
         return 0;
    }

    Code:
     del MAIN.exe
     g++ -fpermissive -o  MAIN.exe MAIN.cpp
    
    
     del Mat_dll.dll
     g++  -shared -o Mat_dll.dll Mat_dll.cpp
     rem  tak prykryvaty
    
    pause

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,253
    Does this even compile?
    Code:
        typedef int (*rezultat_vydaj_nazovni_functija)(int, int, char[250]);
        rezultat_vydaj_nazovni_functija prezultat_vydaj_nazovni_functija = (rezultat_vydaj_nazovni_functija)GetProcAddress(deskriptor_modula, "rezultat_vydaj_nazovni_functija");
        if (prezultat_vydaj_nazovni_functija != NULL)
        {
            char vybir[250][4] = { "minus", "plus", "mnozhyty", "dilyty" };
            int i=0;
            std::cout << vybir[250][0] << " " << "vvedy" << " 0" << std::endl;
             std::cout << vybir[250][1] << " " << "vvedy" << " 1" << std::endl;
             std::cout << vybir[250][2] << " " << "vvedy" << " 2" << std::endl;
             std::cout << vybir[250][3] << " " << "vvedy" << " 3" << std::endl;
            std::cin >> i;
     
            int rezultat = (*prezultat_vydaj_nazovni_functija) (70, 10, vybir[250][i]);
           //int min mat1;
           std::cout << rezultat << std::endl;
        }
    You have array overruns and incompatible types all over the place.

    Perhaps
    Code:
        typedef int (*rezultat_vydaj_nazovni_functija)(int, int, char[250]);
        rezultat_vydaj_nazovni_functija prezultat_vydaj_nazovni_functija = (rezultat_vydaj_nazovni_functija)GetProcAddress(deskriptor_modula, "rezultat_vydaj_nazovni_functija");
        if (prezultat_vydaj_nazovni_functija != NULL)
        {
            char vybir[4][250] = { "minus", "plus", "mnozhyty", "dilyty" };
            int i=0;
            std::cout << vybir[0] << " " << "vvedy" << " 0" << std::endl;
             std::cout << vybir[1] << " " << "vvedy" << " 1" << std::endl;
             std::cout << vybir[2] << " " << "vvedy" << " 2" << std::endl;
             std::cout << vybir[3] << " " << "vvedy" << " 3" << std::endl;
            std::cin >> i;
     
            int rezultat = (*prezultat_vydaj_nazovni_functija) (70, 10, vybir[i]);
           //int min mat1;
           std::cout << rezultat << std::endl;
        }
    The 250 size is both arbitrary and unnecessary. It's just a \0 terminated char pointer at the end of the day.
    Code:
        typedef int (*rezultat_vydaj_nazovni_functija)(int, int, char[]);
        rezultat_vydaj_nazovni_functija prezultat_vydaj_nazovni_functija = (rezultat_vydaj_nazovni_functija)GetProcAddress(deskriptor_modula, "rezultat_vydaj_nazovni_functija");
        if (prezultat_vydaj_nazovni_functija != NULL)
        {
            char *vybir[4] = { "minus", "plus", "mnozhyty", "dilyty" };
            int i=0;
            std::cout << vybir[0] << " " << "vvedy" << " 0" << std::endl;
             std::cout << vybir[1] << " " << "vvedy" << " 1" << std::endl;
             std::cout << vybir[2] << " " << "vvedy" << " 2" << std::endl;
             std::cout << vybir[3] << " " << "vvedy" << " 3" << std::endl;
            std::cin >> i;
     
            int rezultat = (*prezultat_vydaj_nazovni_functija) (70, 10, vybir[i]);
           //int min mat1;
           std::cout << rezultat << std::endl;
        }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2015
    Posts
    112
    Thank you very much for the answer! I really appreciate your advice. And I still want to attach the archive to this topic. I'll try again.
    dll_my.zip — RGhost — файлообменник
    Last edited by Dmy; 4 Weeks Ago at 01:37 PM.

  4. #4

  5. #5
    Registered User john.c's Avatar
    Join Date
    Dec 2017
    Posts
    605
    Google translate is funny.


    Is anyone else wary of clicking on Russian sites?
    The first one is an island off the west coast of Africa.
    Let him who is not come to logic be plagued with continuous and everlasting filth.
    - John of Salisbury, 1160

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please, append the necessary code skillfully art created.
    By Дмитро in forum C++ Programming
    Replies: 3
    Last Post: 12-29-2015, 04:40 PM
  2. [HOWTO] write classes headers
    By gibbofresco in forum C++ Programming
    Replies: 9
    Last Post: 10-26-2007, 12:32 PM
  3. How to write Java style classes in C++
    By Aardappel in forum C++ Programming
    Replies: 0
    Last Post: 12-28-2005, 10:17 AM
  4. write/read list of classes to file
    By nijmegen in forum C++ Programming
    Replies: 2
    Last Post: 08-06-2002, 09:23 AM
  5. any good way to write sprite/animation classes for a game?
    By compjinx in forum Game Programming
    Replies: 2
    Last Post: 03-28-2002, 01:22 AM

Tags for this Thread