First of all, it seems that you've overcomplicating your templates. In a Point
, can x
, y
, and z
be different types? I'm guessing not, so you only need one template parameter:
template <typename T>
struct Point{
T x;
T y;
T z;
// ...
};
The same should be done for RectBounds
.
Now, the reason you're actually getting an error is due to the parameter types of your functions contains
and intersects
. You have used Point
and RectBounds
. However, these name templates, not types. Function parameters need to have types. Since we have given Point
only one template parameter now, a type might be Point<float>
. As you can see, we need to provide a template argument. So the following would work:
inline bool contains(Point<float> & p) {
However, it seems that you probably don't want to fix it to some specific type. You either want to accept only Point
s that have the same type as the template argument for RectBounds
:
inline bool contains(Point<T> & p) {
Or you want to be able to accept Point
s with arbitrary type, in which case you can make contains
a member function template:
template <typename U>
inline bool contains(Point<U> & p) {