How can I fix this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream.h>
template<class T>
class CSquare
{
	T width,height;
public:
	CSquare() {}
	CSquare(T w,T h){width=w; height=h;}
	T operator+(CSquare);
	void Show() {cout<<width<<endl<<height;}
};
template<class T>
T CSquare<T>::operator+(CSquare arg)
{
	CSquare<T> ret;
	ret.width = width + arg.width;
	ret.height = height + arg.height;
	return ret;
}

void main()
{
	CSquare<int> a(3,4);
	CSquare<int> b(6,7);
	CSquare<int> c = a + b;  //Error: Cannot convert 'int' to 'CSquare<int>'
	c.Show();
}

Hello guys. How can I fix that error? Thanks..
line 13

CSquare<T> CSquare<T>::operator+(CSquare arg)
Thanks kev82.. it works :)
Topic archived. No new replies allowed.