   error: BodyViewerWidget' is not a template type
  Here goes my code#ifndef BODYVIEWERWIDGET_H#define BODYVIEWERWIDGET_H#include <QString>#include <QWidget>#include <QTextEdit>#include "contentencodingtraits.h"template <typename T>class BodyViewerWidget: public T{private:QString type_;public:    BodyViewerWidget();public:void setType(const QString& type);const QString& type() const;QWidget* makeWidget() const;};template <typename T>BodyViewerWidget<T>::BodyViewerWidget(){this->TemplateParamenterMustBe_ContentEncodingTraits_Derived();}template <typename T>void BodyViewerWidget<T>::setType(const QString& type){type_ = type;}template <typename T>const QString& BodyViewerWidget<T>::type() const{return type_;}template <typename T>QWidget* BodyViewerWidget<T>::makeWidget() const{QWidget* widget;switch(type_){case "text/plain":widget = new QTextEdit;static_cast<QTextEdit*>(widget)->setPlainText(this->decode());break;case "text/html":widget = new QTextEdit;static_cast<QTextEdit*>(widget)->setHtml(this->decode());break;case "text/richtext":case "text/enriched":widget = new QTextEdit;static_cast<QTextEdit*>(widget)->setHtml(this->decode());break;}return widget;}struct BodyViewer{public:template <typename T>static BodyViewerWidget<T>* Widget(const QString& encoding);};#endif // BODYVIEWERWIDGET_HI am gettings the following errorbodyviewerwidget.h:10: error: ‘BodyViewerWidget’ is not a template typebodyviewerwidget.h:22: error: ‘BodyViewerWidget’ is not a templatebodyviewerwidget.h:22: error: explicit qualification in declaration of ‘BodyViewerWidget BodyViewerWidget()’bodyviewerwidget.h: In function ‘BodyViewerWidget BodyViewerWidget()’:bodyviewerwidget.h:22: error: return type ‘struct BodyViewerWidget’ is incompletebodyviewerwidget.h:23: error: invalid use of ‘this’ in non-member functionbodyviewerwidget.h: At global scope:bodyviewerwidget.h:27: error: expected initializer before ‘::’ tokenbodyviewerwidget.h:32: error: expected initializer before ‘::’ tokenbodyviewerwidget.h:37: error: expected initializer before ‘::’ tokenbodyviewerwidget.h:60: error: expected initializer before ‘*’ tokenAny Idea ??Thanks   
  Can you post the .cpp file that uses this header?   ;  Here goes the .cpp file#include "bodyviewerwidget.h"#include "bit7encodingtraits.h"#include "bit8encodingtraits.h"#include "quotedprintableencodingtraits.h"#include "base64encodingtraits.h"#include "binaryencodingtraits.h"template <typename T>BodyViewerWidget<T>* BodyViewer::Widget(const QString& encoding){switch(encoding){case "7bit":return new BodyViewerWidget<Bit7EncodingTraits>;break;case "8bit":return new BodyViewerWidget<Bit8EncodingTraits>;break;case "quoted-printable":return new BodyViewerWidget<QuotedPrintableEncodingTraits>;break;case "base64":return new BodyViewerWidget<Base64EncodingTraits>;break;case "binary":return new BodyViewerWidget<BinaryEncodingTraits>;break;}}But even if I comment out whole BodyViewer class in bothe places (.h and .cpp file) The error remains same.Thanks;  What compiler are you using? I tried compiling your code (replacing the QString and other classes with my own dummy classes) and it worked fine under VC++ 2005.Also, I'm not sure what you mean when you say the error remains after commenting out code - if you have truly commented out the entirety of code related to BodyViewerWidget, I can't see how there would be any possibility of a compiler error?!   ;  I am using gcc version 4.3.2 have you #included the code in your .cpp file ?if you just keep it in a .h file and don't include it, you will not get that error message cause that code will not come to the compiler.I said that even if I remove the BodyViewer class defenition and declaration I do get the same error message.in bodyviewer.h file there are two classes BodyViewerWidget and BodyViewer (down the page) and I said If I comment out the Bodyviewer Class I still get the errorwhich proves The error is definitely coming from BodyViewerWidget Class.Thanks.   ;  Create the following foo.cpp file:template<typename T>class BodyViewerWidget {};does it compile?Backup your copy of bodyviewerwidget.h and bodyviewerwidget.cpp.Make the body of bodyviewerwidget.h consist of only:template<typename T>class BodyViewerWidget {};Does it get past that?  If not, remove all #includes before it.  Does it work?(#include "contentencodingtraits.h" is a possible source of quite arbitrary bugs if it is malformed).;  You don't happen to have a forward declaration for the BodyViewerWidget class in one of your headers, do you?   ;  Since when have you been able to switch on a string and have a templated function which is not specialised in a source file?   ;  Ya, BodyViewer::Widget won't compile.  It will require a passed in template parameter T.  And then all but one of the return statements will be illegal.If he creates a base BodyViewerWidgetInterface class for all BodyViewerWidget<T>s, then remove the template parameter from:template <typename T>static BodyViewerWidget<T>* Widget(const QString& encoding things will work better.Quote:You don't happen to have a forward declaration for the BodyViewerWidget class in one of your headers, do you?Ya, that is probably it.In #include "contentencodingtraits.h" or a file included from there.   ;  Actually the problem was not in the Class.First I planned to make BodyViewerWidget a simple class not TemplateSo I didclass BodyViewerWidget;BodyViewerWidget* mailViewerWidget;in another class.that compiler was getting before reading bodyviewerwidget.hand complaining BodyViewerWidget is not a Template.I've solved this issue by multiple inheritancenow BodyViewerWidget inherirts both T and QWidget;and in that Class  I am doingclass QWidget;QWidget* mailViewerWidget;insteadand while constructing the object I am using BodyViewerWidget<T>and static BodyViewer::Widget(const QString& encoding) now returns QWidget*   