I'm trying to call my templated function with no success :(
My memaddr.h:
#ifndef __MEM_ADDR_WRITER__
#define __MEM_ADDR_WRITER__
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
namespace MemAddr {
template <typename WRITABLE>
int WriteMemoryAddress(const char* process, unsigned long address, WRITABLE value);
}
#endif
The call:
byte value = 0xEB;
MemAddr::WriteMemoryAddress("jamp.exe", 0x004392D2, value);
Error Message:
undefined reference to `int MemAddr::WriteMemoryAddress<unsigned char>(char const*, unsigned long, unsigned char)`
Answer: Templates needs to be defined in headers.. (@Shaggi)
The function template
template <typename WRITABLE>
int WriteMemoryAddress(const char* process, unsigned long address, WRITABLE value);
is not defined. Include its definition in the header file (memaddr.h):
template <typename WRITABLE>
int WriteMemoryAddress(const char* process, unsigned long address, WRITABLE value)
{
/* do something */
}
The function template will be instantiated once when you use it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.