【c++】
class City
{
Point location;
char name[MAX_CITY_NAME];
public:
double distance(const City & other) const
{
return location.distance(other.location);
}
Point get_location(void) const
{
return location;
}
// other methods and constructors here
};
class Point
{
double x,y;
public:
double distance( const Point & p){ //code }
// other methods and constructors here
};
Point get_location(void)
其实就是
Point get_location()
返回一个代表当前位置的 Point 类型的对象
声明了一个函数,建议没学明白c++的高级应用之前不要接触这些基础知识,那是好好学习的人才会干的事情。