There is class Road with its Road.h and Road.cpp which contains implementation of method isInside(int x, int y) and the road rectangle sizes. And there is class Car with its .h and .cpp and it contains int x and int y. How can I from Car::move() method check if the car is inside the Road?
Car::move()
{
bool isIn = // isInside(x,y) How to do this? It is in another class
}
If the method
isInsidea static method in theRoadclass, then you will call it using the class scope operator – something like thisRoad::isInside(x,y);. If, in theCarclass you have an object of theRoadclass, then based on whether it is an object or a pointer, you can call it asroadObject.isInside(x,y);orroadObjectPointer->isInside(x,y);