【发布时间】:2013-01-16 16:33:38
【问题描述】:
我的主课如下所示:
#include "stdafx.h"
using namespace std;
class MemoryAddressing : Memory {
int _tmain(int argc, _TCHAR* argv[])
{
Memory mem;
int hp = Memory.ReadOffset(0x000000);
}
}
然后我有第二节课:
#include <windows.h>
#include <iostream>
using namespace std;
static class Memory {
public : static int ReadOffset(DWORD offset) {
DWORD address = 0x000000;
DWORD pid;
HWND hwnd;
int value = 0;
hwnd = FindWindow(NULL, L"");
if(!hwnd) {
cout << "error 01: Client not found, exiting...\n";
Sleep(2000);
}else {
GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_VM_READ, 0, pid);
if(!handle) {
cout << "error 02: no permissions to read process";
}
else {
ReadProcessMemory(handle, (void*) offset, &value, sizeof(value), 0);
}
}
}
};
很明显,我试图在我的MemoryAddressing 类中从我的Memory 类继承ReadOffset 方法。我不知道该怎么做,似乎班级无法交流。
我已经了解 Java 和 C#,但我认为 C++ 非常不同。
【问题讨论】:
-
使用公共继承。即:
class MemoryAddressing : public Memory -
为什么要创建一个mem局部变量?
-
这段代码真的是 C++ 吗?
-
你期待什么输出?你得到什么输出? (请复制并粘贴)。
-
我听说有人有
Memory课程,但我从没想过这是真的……
标签: c++ class memory inheritance methods