Peter_APIIT
January 14th, 2009, 03:11 AM
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)?
#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();
#endif
#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;
}
}
// =============================================
The purpose of creating the library is to import to certain project with few clicks.
Thanks for your help.
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)?
#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();
#endif
#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;
}
}
// =============================================
The purpose of creating the library is to import to certain project with few clicks.
Thanks for your help.