使用指针表达式 必须具有类类型错误 c++

working with pointers Expression Must have class type error c++

本文关键字:类型 错误 c++ 指针 表达式      更新时间:2023-10-16
>#include "stdafx.h"
>#include <Windows.h>
>#include <iostream>

using namespace std;

HANDLE pHandle;
class Player
{
public:
//Client Player
DWORD_PTR clientPlayer;
char Name[0x10];
unsigned int m_teamId;
//ClientControllableEntity
DWORD_PTR clientSoldier;
BYTE isOccluded;
//ClientSoldierReplication
DWORD_PTR clientReplication;
int state;
//LifeModule
DWORD_PTR healthcomponent;
FLOAT health;
};
class LocalPlayer : public Player
{
public:

DWORD_PTR VehicleVelocityA;
DWORD_PTR VehicleVelocityB;
DWORD_PTR VehicleVelocityC;
INT VehicleSpeed;
};
LocalPlayer lPlayer;
int readSpeed(LocalPlayer* localPlayer){
ReadProcessMemory(pHandle, (void*)(localPlayer->clientSoldier + 0x0280),     &localPlayer->VehicleVelocityA, sizeof(localPlayer->VehicleVelocityA), NULL);
ReadProcessMemory(pHandle, (void*)(localPlayer->clientSoldier + 0x0284), &localPlayer->VehicleVelocityB, sizeof(localPlayer->VehicleVelocityB), NULL);
ReadProcessMemory(pHandle, (void*)(localPlayer->clientSoldier + 0x0288), &localPlayer->VehicleVelocityC, sizeof(localPlayer->VehicleVelocityC), NULL);
double VelocityAX = pow(localPlayer->VehicleVelocityA.x, 2);
double VelocityBX = pow(localPlayer->VehicleVelocityB.x, 2);
double VelocityCX = pow(localPlayer->VehicleVelocityC.x, 2);
localPlayer->VehicleSpeed = 0;
localPlayer->VehicleSpeed = sqrt(VelocityAX + VelocityBX + VelocityCX) * 3.6f;
}

有人可以帮我处理上面的代码吗?我得到表达式必须在这些行有类错误

double VelocityAX = pow(localPlayer->VehicleVelocityA.x, 2);
double VelocityBX = pow(localPlayer->VehicleVelocityB.x, 2);
double VelocityCX = pow(localPlayer->VehicleVelocityC.x, 2);

它告诉我本地玩家必须具有类类型。有人可以帮我调试这段代码吗,它困扰了我几个小时。

DWORD_PTR是一个指针,而不是一个结构。这就是为什么它给出错误的原因。 pow期望doublefloat的函数。

VehicleVelocityA和其他变量声明为 doublefloat 或结构包含xdoublefloat