When I try to compile this, I get this linker error:
LNK2001 unresolved external symbol "public: static int HooksXD::night" (?night@HooksXD@@2HA)
The header is this:
class HooksXD
{
public:
static void XD3();
static int night;
static int night2;
};
Variables are public not private because I need to access them from other voids witch are not in the same class.
The cpp file:
HooksXD lmao;
void HooksXD::XD3()
{
//this void will be called from other cpp files
lmao.night = 1;
lmao.night2 = 1;
};
bool __stdcall CreateMoveClient_Hooked(float frametime, CUserCmd* pCmd)
{
if (lmao.night = 1)
{
//some code
lmao.night++;
}
}
You have only declared night
and night2
, they still need definitions. (because they're static
)
In your cpp file :
int HooksXD::night = 0;
int HooksXD::night2 = 0;
And then to access one don't do lmao.night
, since it's a static you should access it through the type name : HooksXD::night
.
Make sure you actually need static
here though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With