我一直得到:未解析的外部符号“public static int __cdecl Memory :: Read(unsigned __int64,unsigned __int64_”,用于我的模板函数声明“Read”
它在一个名为“memory”的类中定义,带有头文件:
#ifndef MEMORY_H
#define MEMORY_H
#include <string>
#include "DataFuncs.h"
using namespace std;
class Memory {
public:
template <typename type>
static type Read(DWORD64 Address, SIZE_T size);
static bool Write(DWORD64 Address, uintptr_t Value, SIZE_T size);
};
#endif
其.cpp定义如下:
#include "Memory.h"
template <typename type>
type Memory::Read(DWORD64 Address, SIZE_T size) {
return Data.Read<type>(Process_ID, Address, size);
}
bool Memory::Write(DWORD64 Address, uintptr_t Value, SIZE_T size) {
if (Data.Write(Address, Value, size))
return true;
return false;
}
在实际用于其他文件之前,不会发生错误。其实施如下:
#include "Memory.h"
#include "Special_Functions.h"
__int32 Special_Functions::Test(){
__int32 x = Memory::Read<__int32>(0x20302, sizeof(__int32));
return x;
}
如果我拿走Memory::Read<__int32>(0x20302, sizeof(__int32));
行并输入return 53
,则不会出现编译问题。知道为什么以及如何解决它?谢谢!