本文共 1543 字,大约阅读时间需要 5 分钟。
class WIN32DLL_API CWin32Dll { public: CWin32Dll(void); // TODO: 在此添加您的方法。 private: int m_nVar; std::string m_strVar; public: void set(int ); void printfValue(); void set_str(const std::string &); void printf_str(); }; extern WIN32DLL_API int nWin32Dll; //这里尤其要注意,当你想创建一个非成员函数时 WIN32DLL_API void printfValue(const int &); WIN32DLL_API int fnWin32Dll(void); |
CWin32Dll::CWin32Dll() { return; } void CWin32Dll::set(int v) { m_nVar = v; } void CWin32Dll::printfValue() { std::cout << m_nVar << std::endl; } void CWin32Dll::set_str(const std::string &str) { m_strVar = str; } void CWin32Dll::printf_str() { std::cout << m_strVar << std::endl; } void printfValue(const int &v) { std::cout << v << std::endl; } |
#include "stdafx.h" #include "../Win32Dll/Win32Dll.h" #pragma comment(lib,"D:/My Documents/Visual Studio 2010/Projects/Win32Dll/Debug/Win32Dll.lib") int _tmain(int argc, _TCHAR* argv[]) { int v = 12; printfValue(v); CWin32Dll obj; obj.set(v); obj.printfValue(); CWin32Dll obj2; obj2.set_str("haha"); obj2.printf_str(); CWin32Dll obj3; obj3.set_str("nono"); obj3.printf_str(); return 0; } |
转载地址:http://gbbll.baihongyu.com/