Jump to content

  • Log In with Google      Sign In   
  • Create Account

Trouble with Templates and error C2039


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Nicholas1991   Members   -  Reputation: 118

Like
0Likes
Like

Posted 18 July 2010 - 01:01 AM

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[i] = ((VertexType*)pEntity->m_pVertices +
pEntity->m_pIndices[idx + i])->position;
m_Points.Add(p[i]);
}
}
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.

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9676

Like
0Likes
Like

Posted 18 July 2010 - 04:32 AM

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.

#3 Nicholas1991   Members   -  Reputation: 118

Like
0Likes
Like

Posted 18 July 2010 - 04:33 AM

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 :).





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS