I'm learning c++ at the moment, and i just learnt about classes, so i decided to make a text game with a badguy and player class, and i was wondering how to refer to other classes variables(like this.health)
from other classes. and wether you have to create an instance of those classes like you do in python, heres my code:
#include <cstdlib>
#include <iostream>
using namespace std;
class Badguy {
private:
int this.health = 10, this.defense = 3;
char this.name = "Orc";
int getAttributesInfo() {
attributes [] = {this.health, this.defense, this.name};
return attributes;
}
} ;
class Player {
private:
srand((1),(7));
int this.attack = rand();
char name = "Player";
int getDamage(void) {
int Badguy.damage = this.attack - defense;
if (Badguy.damage > Badguy.defense) {
Badguy.health -= Badguy.damage;
}
}
} ;
int main() {
}
And if you could tell me about any errors in this that would be appreciated :)