my problem is the Point plus(Point). how should I declare it and all that.

// point.h -- This creates a point with both x and y of type integer

#include <iostream>
using namespace std;

template<typename T>
class Point {
	private:
		T x;
		T y;
	public:
		Point(T,T);
		Point();

                  void set_x(T);
                  void set_y(T);
                  T get_x();
                  T get_y();
	         Point plus(Point);
		void print();
};
 


template<typename T>
Point<T>::Point(T initx, T inity) {
	// If no coordinates are given, the default in (0,0)
	x = initx;
	y = inity;
}

template<typename T>
Point<T>::Point() {
	x = 0;
	y = 0;
}

template<typename T>
void Point<T>::set_x(T setx) {
	x = setx;
}

template<typename T>
void Point<T>::set_y(T sety) {
	y = sety;
}

template<typename T>
T Point<T>::get_x() {
	return x;
}

template<typename T>
T Point<T>::get_y() {
	return y;
}

template<typename T>
Point Point<T>::plus(Point operand2) {
	Point temp;
	temp.set_x(get_x() + operand2.get_x());
    temp.set_y(get_y() + operand2.get_y());
	return temp;
}

template<typename T>
void Point<T>::print() {

	cout << "(" << x << "," << y << ")";

}
template<typename T>
Point<T> Point<T>::plus(Point<T> operand2) {
	Point temp;
	temp.set_x(get_x() + operand2.get_x());
	temp.set_y(get_y() + operand2.get_y());
	return temp;
}

thanks for the fast response :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.