P
Peter Davis
I'm trying to define a template class ...
namespace abc
{
class Node;
typedef boost::shared_ptr<Node> NodePtr;
template <typename Derived> class Cloneable
{
public:
virtual NodePtr clone() const
{
Derived *d = new Derived(static_cast<const
Derived&>(*this));
return d->makeNodePtr(); }
};
....
and then use that as a superclass of another class ...
#include "abc/dom/Node.hpp" // The file above!
namespace abc
{
class Node : public BaseObject, Cloneable<Node>
{
....
This follows, as I understand it, the 'curiously recurring template'
pattern. However, when I try to compile (Visual Studio 2008), I get the
error:
C2504: 'CloneableImpl' : base class undefined.
on the line defining class Node. I don't understand why, since the cpp
file includes the header file in which the template Cloneable is
defined, and they're in the same namespace.
Any insights?
Thanks!
-pd
namespace abc
{
class Node;
typedef boost::shared_ptr<Node> NodePtr;
template <typename Derived> class Cloneable
{
public:
virtual NodePtr clone() const
{
Derived *d = new Derived(static_cast<const
Derived&>(*this));
return d->makeNodePtr(); }
};
....
and then use that as a superclass of another class ...
#include "abc/dom/Node.hpp" // The file above!
namespace abc
{
class Node : public BaseObject, Cloneable<Node>
{
....
This follows, as I understand it, the 'curiously recurring template'
pattern. However, when I try to compile (Visual Studio 2008), I get the
error:
C2504: 'CloneableImpl' : base class undefined.
on the line defining class Node. I don't understand why, since the cpp
file includes the header file in which the template Cloneable is
defined, and they're in the same namespace.
Any insights?
Thanks!
-pd