Problem encountered in writing a class which extends QList
Jens Zurheide
jens.zurheide at gmx.de
Sat Mar 2 15:35:50 GMT 2002
Saturday 02 March 2002 05:36 Dung Patrick
>I need a new Class which extends QList. I have the following code but get
> error:
QList is a template class. If you do not know what this is a good book
about C++ might help because this is an advanced feature of the programming
language C++ and can not be explained in a short posting. A very tearse
explanation is: this list can become a list holding any type you want.
>
>rule.h:
>#ifndef RULE_H
>#define RULE_H
>#include <qlist.h>
>
If you want Rule to be as generic as QList you should write something like
this:
template< typename T >
class Rule : public QList<T> {
public :
Rule();
virtual ~Rule();
};
>class Rule : public QList {
>public:
>Rule();
>~Rule();
>};
>#endif
>
>rule.cpp:
>#include "rule.h"
template< typename T>
Rule<T>::Rule()
{
}
template< typename T>
Rule<T>::~Rule()
{
}
>Rule::Rule(){
>}
>Rule::~Rule(){
>}
>
and somewhere else
Rule<type_of_what_you_want> r;
However if you don't want to be Rule as generic as QList but a list to a
specific data type you might want to declare your class like:
class Rule : public QList<whatever_type_you_want> {
public:
Rule();
~Rule();
};
Rule::Rule(){
}
Rule::~Rule(){
}
Hope this helps.
Jens
-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«
More information about the KDevelop
mailing list