''的原型与'类中的任何一个'不匹配''

时间:2014-08-18 09:33:58

标签: c++

我在编写程序时遇到了问题:

  

int SROMemory :: ReadString(unsigned int)的原型与类SROMemory中的任何一个都不匹配

怎么回事?

这是我的Dev C ++项目的链接:https://www.sendspace.com/file/uop8m8

#include "memory.h"

SROMemory::SROMemory()
{
          GetWindowThreadProcessId(FindWindow(NULL, (LPCSTR)TEXT("Tibia")), &PROC_ID);
          PROC_HANDLE = OpenProcess(0x10, false, PROC_ID);
}

int SROMemory::ReadString(unsigned int Pointer)
{
        char cValue[24] = "\0";
        ReadProcessMemory(PROC_HANDLE, (LPVOID)Pointer, &cValue, sizeof(cValue), NULL);
        string Value = cValue;
        return Value;
}

这是main.cpp:

#include <iostream>
#include "memory.h"

using namespace std;

int main(void)
{
     bool exit = false;

     SROMemory Memory;

     string loginPass = Memory.ReadString(0x78F554);

     cout << "LoginPass: " << loginPass << "\n";

     do
     {

     }while(!exit);
}

这是memory.cpp:

#include "memory.h"

SROMemory::SROMemory()
{
          GetWindowThreadProcessId(FindWindow(NULL, (LPCSTR)TEXT("Tibia")), &PROC_ID);
          PROC_HANDLE = OpenProcess(0x10, false, PROC_ID);
}

int SROMemory::ReadString(unsigned int Pointer)
{
        char cValue[24] = "\0";
        ReadProcessMemory(PROC_HANDLE, (LPVOID)Pointer, &cValue, sizeof(cValue), NULL);
        string Value = cValue;
        return Value;
}
是的,我忘记了memory.h:

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>

using namespace std;

class SROMemory
{
    public:
        SROMemory();
        int ReadPointer(unsigned int Pointer);
        int ReadOffset(unsigned int Offset);
        string ReadString(unsigned int Pointer);
    private:
        DWORD PROC_ID;
        HANDLE PROC_HANDLE;
};

1 个答案:

答案 0 :(得分:4)

函数签名(在源文件中)与原型的签名(标题中的声明)不匹配:更改源文件中的以下行:

int SROMemory::ReadString(unsigned int Pointer)

string SROMemory::ReadString(unsigned int Pointer)

根据Prototype... does not match any in Class... (error). g++的另一种可能性是,您的源文件包含错误的头文件