VS2015中建立dll工程
1. 文件——>新建项目——>模板——>Visual C++——>MFC——>MFC DLL
输入工程名first_dll
2.下一步——>MFC扩展DLL
3.建立first_dll.h头文件
#pragma once
#ifndef __FIRST_DLL_H__
#define __FIRST_DLL_H__
#include "iostream"
#include "string"
#include "thread"
#include "mutex"
using namespace std;
class Student
{
public:
void setMyAge(int age);
void setMyName(char *name);
void subFunc();
void startThread();
private:
int age = 0;
char name[32];
static volatile int mId;
static std::mutex mMutex;
};
#endif
在first_dll.cpp中输入
// first_dll.cpp : 定义 DLL 的初始化例程。
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include "iostream"
#include "first_dll.h"
using namespace std;
volatile int Student::mId = 0;
std::mutex Student::mMutex;
void Student::setMyAge(int age) {
std::cout << "Student::mySetAge" <<