So I'm still some what new to C++ programming and very new at templates. I am trying to make a basic template class (a node if you will) that holds some generic data and a double. I then want to make another class contain a set of the previously mentioned template class.
Im having trouble with the less-than operator as its going to server as my comparator.
Node&Tree.h
#ifndef _POINTNODE_H_
#define _POINTNODE_
#include <set>
template<typename T>
class PointNode {
public:
PointNode(double p){ m_point = p;}
~PointNode();
bool operator < (const &PointNode<T> p1) const;
private:
const double m_point;
T *m_data;
};
template <typename T>
class PointTree {
public:
PointTree();
~PointTree();
private:
std::set<PointNode<T> > tree;
};
#endif
Node&Tree.cpp
#inlcude "Node&Tree.h"
#include <set>
template<typename T>
bool PointNode<T>:: operator < (const &PointNode<T> p1) const{
return m_point < p1.m_point;
}
Im getting the folowing errors
Node&Tree.cpp:5:39: error: ISO C++ forbids declaration of ‘parameter’ with no type [- fpermissive]
Node&Tree.cpp:5:39: error: expected ‘,’ or ‘...’
Node&Tree.cpp:5:6: error: prototype for ‘bool PointNode<T>::operator<(const int&) const’ does not match any in class ‘PointNode<T>’
Node&Tree.h:15:8: error: candidate is: bool PointNode<T>::operator<(const int&)"
This is largely unimplemented but I just wanted to get the basics to compile at least... And any pointers on the code or if you think I'm going about this all wrong please tell me!
Any help would be amazing!