sunil.thaha
7th February 2006, 10:14
Hi Guys,
I want to save the contents of the QPtrList to the Database.
So Here is what i did
//DataList.h
template <typename T>
class DataList : public QPtrList< T > {
public:
DataList(){};
virtual ~DataList(){};
bool save();
int lastError() const;
private:
void setLastError( int iError );
private:
int m_iLastError;
};
//DataList.cpp
template < typename T >
DataList<T>::DataList()
:m_iLastError( QueryResult::ErrorNotSet ) {}
template < typename T >
bool DataList<T>::save() {
DEBUG_WHERE();
for ( T* pDataItem = first(); pDataItem; next() ) {
bool bOperationFailed = true;
if( pDataItem->indicator() == DataListItem::Inserted ) {
bOperationFailed = pDataItem->insert();
} else if( pDataItem->indicator() == DataListItem::Updated ) {
bOperationFailed = pDataItem->update();
} else if( pDataItem->indicator() == DataListItem::Deleted ) {
bOperationFailed = pDataItem->remove();
}
if( bOperationFailed ) {
setLastError( pDataItem->lastError() );
return false;
}
}
return true;
}
But g++ gives me the Following Error
BusinessLogic/DataList.cpp: In member function `bool DataList<T>::save()':
BusinessLogic/DataList.cpp:10: error: there are no arguments to `first' that depend on a template parameter, so a declaration of `first' must be available
BusinessLogic/DataList.cpp:10: error: (if you use `-fpermissive', G++ will accept your code, but allowing theuse of an undeclared name is deprecated)
BusinessLogic/DataList.cpp:10: error: there are no arguments to `next' that depend on a template parameter, so a declaration of `next' must be available
Now where I am i going wrong
Please Help
I want to save the contents of the QPtrList to the Database.
So Here is what i did
//DataList.h
template <typename T>
class DataList : public QPtrList< T > {
public:
DataList(){};
virtual ~DataList(){};
bool save();
int lastError() const;
private:
void setLastError( int iError );
private:
int m_iLastError;
};
//DataList.cpp
template < typename T >
DataList<T>::DataList()
:m_iLastError( QueryResult::ErrorNotSet ) {}
template < typename T >
bool DataList<T>::save() {
DEBUG_WHERE();
for ( T* pDataItem = first(); pDataItem; next() ) {
bool bOperationFailed = true;
if( pDataItem->indicator() == DataListItem::Inserted ) {
bOperationFailed = pDataItem->insert();
} else if( pDataItem->indicator() == DataListItem::Updated ) {
bOperationFailed = pDataItem->update();
} else if( pDataItem->indicator() == DataListItem::Deleted ) {
bOperationFailed = pDataItem->remove();
}
if( bOperationFailed ) {
setLastError( pDataItem->lastError() );
return false;
}
}
return true;
}
But g++ gives me the Following Error
BusinessLogic/DataList.cpp: In member function `bool DataList<T>::save()':
BusinessLogic/DataList.cpp:10: error: there are no arguments to `first' that depend on a template parameter, so a declaration of `first' must be available
BusinessLogic/DataList.cpp:10: error: (if you use `-fpermissive', G++ will accept your code, but allowing theuse of an undeclared name is deprecated)
BusinessLogic/DataList.cpp:10: error: there are no arguments to `next' that depend on a template parameter, so a declaration of `next' must be available
Now where I am i going wrong
Please Help