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

Edited 3 Years Ago by Elixir42

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

Edited 3 Years Ago by Banfa

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

  • Me << Takes_Big_Sigh_Of_Relief*
This question has already been answered. Start a new discussion instead.