temlate class

A

Active8

Maybe it's been so long that I forgot something but I can't remember
the solution to this compiler error:

error C2039: '__ctor' : is not a member of 'GFX<class T>'
error C2935: 'GFX<class T>' : template-class-id redefined as a
global function

gfx.h

#include <canvas.h>

template <class T>
class GFX : public MCCanvas<class T>
{
public:
GFX();
// GFX(T* parent, wxPoint point, wxSize size);
~GFX(){}

private:
};

gfx.cpp

#include "gfx.h"

template <class T>
GFX<class T>::GFX(){}

It does this whether I implement the class in the header or the cpp
file and regardless of whether it's for the default ctor, or
another. MCCanvas is a template class and it compiles fine.

TIA
 
V

Victor Bazarov

Active8 said:
Maybe it's been so long that I forgot something but I can't remember
the solution to this compiler error:

error C2039: '__ctor' : is not a member of 'GFX<class T>'
error C2935: 'GFX<class T>' : template-class-id redefined as a
global function

gfx.h

#include <canvas.h>

template <class T>
class GFX : public MCCanvas<class T>
{
public:
GFX();
// GFX(T* parent, wxPoint point, wxSize size);
~GFX(){}

private:
};

gfx.cpp

#include "gfx.h"

template <class T>
GFX<class T>::GFX(){}

It does this whether I implement the class in the header or the cpp
file and regardless of whether it's for the default ctor, or
another. MCCanvas is a template class and it compiles fine.

It doesn't matter where you put it, the code ends up in a source file
anyway, after you include the "header" file.

Have you tried dropping the second keyword 'class' from the c-tor
definition and also from the declaration of the base class?

template<class T> class GFX : public MCCanvas<T> ...
...
template<class T> GFX<T>::GFX() {}

They are not only superfluous, they are syntax errors, AFAIK.

V
 
A

Active8

Have you tried dropping the second keyword 'class' from the c-tor
definition and also from the declaration of the base class?

template<class T> class GFX : public MCCanvas<T> ...
...
template<class T> GFX<T>::GFX() {}

They are not only superfluous, they are syntax errors, AFAIK.
Ah... I'd dropped one but not the other, thanks. It's goofy because
the code below works just fine. The only diff here is that the base
class wxScrolledWindow is not templatized:

template <class T>
class MCCanvas : public wxScrolledWindow
{
public:
MCCanvas(T* parent, wxPoint& point = wxDefaultSize, wxSize& size =
wxDefaultPosition);
~MCCanvas(){}
MCCanvas(){}
};

template <class T>
MCCanvas<class T>::MCCanvas(T* parent, wxPoint& point, wxSize& size)
: wxScrolledWindow( (wxWindow*)parent, -1, point, size),
....
{}

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top