Trouble with Templates and error C2039

This topic is 2778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello everyone,

I'm having some trouble with my application. Using the book "Spieleprogrammierung mit DirectX 11 und C++" I try to get startet with game programming. However, I must say that I have already found some mistakes in the book (Is it possible that Visual Studio Express 2008 (recommended by the author) and 2010 differ so much? I don't think so). Until now I could solve them myself with a bit of Internet research. But since I'm new to C++ (used Java before) this time I can't make out how to cange my application to make it run.

"error C2039: '{ctor}': Ist kein Element von" (Is no element of)
This is the part the compiler complains about:
The code is in DynamicEntity.h, the definition of the constructor is in OctreeNode.h
template<class VertexType, bool bIndexed, typename IndexType>     OctreeNode::OctreeNode(const DynamicEntity<VertexType, bIndexed, IndexType> *pEntity) :		m_bbMin(pEntity->m_bbMin), m_bbMax(pEntity->m_bbMax)    {        for (UINT64 idx = 0; idx < pEntity->m_nIndices; idx += 3)        {            D3DXVECTOR3 p[3];             for(int i = 0; i < 3; i++)            {                p = ((VertexType*)pEntity->m_pVertices +                     pEntity->m_pIndices[idx + i])->position;                m_Points.Add(p);            }        }        CreateChildNodes();        }

This might also be important:
In DynamicEntity.h
template<class VertexType, bool bIndexed, typename IndexType>	class DynamicEntity : public Visual {		friend class OctreeNode;        //....

And in OctreeNode.h
template<class VertexType, bool bIndexed=true, typename IndexType = UINT16>	class DynamicEntity;	class OctreeNode {        //...

Since the project is already pretty extensive I don't want to post all of the code here. But if you need further information I will post some more.

BTW: Why is there no preview Button? I would like to see how my post looks like before actually posting it.

Share on other sites
Insufficient information. At the very least mention which expression is failing and why you think it should succeed.

Also there is a preview. It's a link directly under the textbox. The preview is slightly buggy, however. It doesn't show the + character properly.

Share on other sites
Ok, this time it was my fault.
I had #include "OctreeNode.h" in DynamicEntity.h and vice versa. Now removed the entry in OctreeNode.h and everything works fine :).