By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

temlate class

P: n/a
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
--
Best Regards,
Mike
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Active8" <re*********@ndbbm.net> wrote...
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
Jul 23 '05 #2

P: n/a
On Mon, 21 Feb 2005 15:38:25 -0500, Victor Bazarov wrote:


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.
--
Best Regards,
Mike
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.