alright i am trying to write a program that implements a class AirborneLocation that stores info on planes in the sky yada, yada, yada....i won't post the whole src code cuz it is hella long but i will post the section that gives me the compiling error
ostream& operator<< (ostream& os, const AirborneLocation& plane){
os << plane.name << ":" << endl;
os << "\tPlane's ID: " << plane.ID << endl;
os << "\tPlane's Class: ";
if (plane.plane_class == 'C')
os << "Civilian";
else
os << "Military";
os << endl;
os << "\tPlane's Location: ";
if (plane.coord_x < 0.0)
os << abs(plane.coord_x) << " km west, ";
else
os << plane.coord_x << " km east, ";
if (plane.coord_y < 0.0)
os << abs(plane.coord_y) << " km south, ";
else
os << plane.coord_y << " km north, ";
if (plane.coord_z < 0.0)
os << abs(plane.coord_z) << " km down";
else
os << plane.coord_z << " km up";
os << endl;
os << "\tDistance to plane: " << plane.distance();
}
it gives me the error:
prog7.cpp: In function `std::ostream& operator<<(std::ostream&, const
AirborneLocation&)':
prog7.cpp:117: error: passing `const AirborneLocation' as `this' argument of `
double AirborneLocation::distance()' discards qualifiers
line 117 in the program is this line:
os << "\tDistance to plane: " << plane.distance();
whats goin on here??