Hello to all expert,
i have create a win32 console project, then dll project and empty project.
Can anyone give me an explanation how to create a dll from native C++(class/Member function)?
Code:#ifndef STOPWATCH #define STOPWATCH #include <string> #include <ctime> class stopwatch { private: std::clock_t elapsed; public: stopwatch(); ~stopwatch(); }; /* Do not put definition in header file to avoid multiple definition through include directive in object files */ void myInitialize(); #endifThe purpose of creating the library is to import to certain project with few clicks.Code:#include <iostream> #include <sstream> #include <fstream> #include <vector> #include <ctime> #include "StopWatch.h" // ============================================= stopwatch::stopwatch() : elapsed(std::clock()) { } // ============================================= stopwatch::~stopwatch() { std::cout << "\nTotal ticks is " << std::clock() - elapsed; std::cout << "\nTotal seconds is " << (std::clock() - elapsed) /CLOCKS_PER_SEC; // 1000 ticks == 1 second } // ============================================= void myInitialize() { //stopwatch sw; std::string* ptr[90000]; for (int loop=0;loop<90000;++loop) { // 50% improvement over dynamic storage allocation // string s; ptr[loop] = new std::string; } } // =============================================
Thanks for your help.




Reply With Quote