// Declare score variables in the Player class
m_nScore;
Player::Init()
{
m_nScore = 0;
}
// Getter
int GetPlayerScore() { return m_nScore; }
// Dynamic Assignment
m_pObjects = new Objects;
m_pObjects->SetPlayer(m_pPlayer);
// Objects class wants to increase or decrease when conditions are met
class Objects
{
private:
Player* m_pPlayer;
public:
void SetPlayer(Player* pl) { m_pPlayer = pl; }
}
Objects::Update()
{
RECT; // Temporary value
if (intersectRect(&rt, &m_pPlayer->GetPlayerVector.rt, &m_vecEnemys.rt))
{
m_vecEnemys.erase(m_vecEnemys.begin() + i);
m_pPlayer->GetPlayerScore() + 50; // This does not work
}
}
Exporting or importing into another class as a getter setter
It's possible, but how can I change the value I brought?
Try a reference.
© 2024 OneMinuteCode. All rights reserved.