DragonflightDesign
Resource contributor
- Messages
- 1,355
- Country

You might not believe this, but I've never really strayed from the path of C over the years. Now I find I'm having to move into C++ and it's becoming a mild nightmare. Google is just not helping with what I know is a relatively simple question (it's probably one of those 'but you should already know it' things). I can't figure out how to get into 'calc_distance' and return the calculated distance to the outside world. The variable 'distance' itself is being recognised as the intellisense will give me 'distance.distance' once the class has been instantiated, but it won't show 'distance.calc_distance'. What did I miss (or misunderstand
)?
Code:
// Calling code
getLatLonDist distance(0.592539, 0.709186, 2.066470, 1.287762);
// Class
class getLatLonDist
{
double lat1, lat2, lon1, lon2;
public:
getLatLonDist(double, double, double, double);
double distance = 0;
double calc_distance(double latA, double latB, double lonA, double lonB)
{
double dlon, dlat;
lat1 = latA;
lat2 = latB;
lon1 = lonA;
lon2 = lonB;
dlat = lat2 - lat1;
dlon = lon2 - lon1;
distance = acos(sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2)*cos(lon1 - lon2));
return distance;
}
};
getLatLonDist::getLatLonDist(double latitudeA, double latitudeB, double longitudeA, double longitudeB)
{
lat1 = latitudeA;
lat2 = latitudeB;
lon1 = longitudeA;
lon2 = longitudeB;
}

