Correct me, if I'm mistaken, but this code

Originally Posted by
sunil.thaha
//DataList.h
template <typename T>
class DataList : public QPtrList< T > {
public:
DataList(){};
// [Skip]
};
//DataList.h
template <typename T>
class DataList : public QPtrList< T > {
public:
DataList(){};
// [Skip]
};
To copy to clipboard, switch view to plain text mode
//DataList.cpp
template < typename T >
DataList<T>::DataList()
:m_iLastError( QueryResult::ErrorNotSet ) {}
//[Skip]
//DataList.cpp
template < typename T >
DataList<T>::DataList()
:m_iLastError( QueryResult::ErrorNotSet ) {}
//[Skip]
To copy to clipboard, switch view to plain text mode
should lead to link error, as Datalist<T>::Datalist() is implemented twice: both in header and in .cpp files. I suggest something like this:
//DataList.h
template <typename T>
class DataList : public QPtrList< T > {
public:
DataList();
// [Skip]
};
//DataList.cpp
template < typename T >
DataList<T>::DataList() :
QPtrList<T>(),
m_iLastError( QueryResult::ErrorNotSet )
{
}
//[Skip]
//DataList.h
template <typename T>
class DataList : public QPtrList< T > {
public:
DataList();
// [Skip]
};
//DataList.cpp
template < typename T >
DataList<T>::DataList() :
QPtrList<T>(),
m_iLastError( QueryResult::ErrorNotSet )
{
}
//[Skip]
To copy to clipboard, switch view to plain text mode
Bookmarks