Everything was running fine, then I made a simple change. Like adding a class or two and bang!!! C2995. Can you spot where I have obviously gone blind and cannot see the error. I have header gaurds throughout the solution, so I dont understand why this is happening. Here are two of the classes which were working before. I tried a clean rebuild also. Question: Is my coding of the template TPhysics.h ok (btw)?
Compile it and see...!

1>------ Build started: Project: DXTB 12, Configuration: Debug Win32 ------
1>  Main.cpp
1>d:\code\dx tuts\projects\dxtb 12\dxtb 12\tphysics.h(76): error C2995: 'TPhysics<T>::TPhysics(void)' : function template has already been defined
1>          d:\code\dx tuts\projects\dxtb 12\dxtb 12\tphysics.h(18) : see declaration of 'TPhysics<T>::TPhysics'
1>d:\code\dx tuts\projects\dxtb 12\dxtb 12\tphysics.h(18): error C2333: 'TPhysics<T>::TPhysics' : error in function declaration; skipping function body
1>          with
1>          [
1>              T=CCamera2D
1>          ]
1>          d:\code\dx tuts\projects\dxtb 12\dxtb 12\ccamera2d.h(40) : see reference to class template instantiation 'TPhysics<T>' being compiled
1>          with
1>          [
1>              T=CCamera2D
1>          ]




/*************************************************************************
**
**  Filename:   TPhysics.h
**  Date:       02/03/2013
**
**************************************************************************/
#ifndef TPhysics_h
#define TPhysics_h

template <class T>
class TPhysics
{
public:
    TPhysics(void)
    {
        // Initialise vars
    }

    void Apply(T* pObject);

    ~TPhysics(void);

private:

};

/*Implementation Here*/

// ********************************************************************* //
// Name: TPhysics                                                        //
// Description: Constructor                                              //
// ********************************************************************* //
template <class T>
TPhysics<T>::TPhysics(void)
{
}// CPhysics

// ********************************************************************* //
// Name: Apply                                                           //
// Description: Applies all calculations.                                //
// ********************************************************************* //
template <class T>
void TPhysics<T>::Apply(T* pObject)
{
} // Apply

// ********************************************************************* //
// Name: ~TCPhysics                                                      //
// Description: Destructor                                               //
// ********************************************************************* //
template <class T>
TPhysics<T>::~TPhysics(void)
{
}// ~CPhysics

#endif // TPhysics_h

/*************************************************************************
**
**  Filename:   CCamera2D.h
**  Date:       02/03/2013
**
**************************************************************************/
#ifndef CCamera2D_h
#define CCamera2D_h

#include "TPhysics.h"

class CCamera2D
{
public:
    CCamera2D(void);
    ~CCamera2D(void);

    TPhysics<CCamera2D> m_Physics;
private:
};

#endif // CCamera2D_h

Recommended Answers

All 2 Replies

You have defined the TPhysics constructor at both line 32 and 52

Oh thank you so much... I have been nose-to-code for so long I have double vision...!!!

  • Me << Takes_Big_Sigh_Of_Relief*
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.