![]() ![]() ![]() ![]() | Member functions in class Point. | Lecture 5 - slide 9 : 39 Program 2 |
#include <cmath> #include <iostream> #include "point.h" template<typename N>Point<N>::Point(double x_coord, double y_coord): x(x_coord), y(y_coord){ } template<typename N>Point<N>::Point(): x(0.0), y(0.0){ } template<typename N> double Point<N>::getx () const{ return x; } template<typename N> double Point<N>::gety () const{ return y; } template<typename N> double Point<N>::distance_to(Point<N> p){ return N::distance_to(*this,p); } template<typename N> bool Point<N>::less_than(const Point<N>& p){ return N::less_than(*this,p); } template<typename N> std::ostream& operator<<(std::ostream& s, const Point<N>& p){ return s << "(" << p.getx() << "," << p.gety() << ")" ; }