I'm trying to access a variable in a class from another class:
Even though xpos is defined as public the compiler says it's not defined in this scope. I'm not sure what the best way to go about this would be.Code:class hero ( public: int xpos; void Move(); ); class monster ( public: int xpos; ); void hero::Move() { if (xpos = Goblin.xpos) {/*collision code*/} }; hero MyHero; monster Goblin;