After working with C# for the past decade or two, my C++ is getting a little rusty.
I'm writing a database class and have an issue with the following method:
CRecordset CAccessDatabaseReader::ExecuteSqlQuery(LPCTSTR pszSqlQuery)
{
CRecordset recordSet(&m_Database);
recordSet.Open(CRecordset::forwardOnly, pszSqlQuery);
return CRecordset(recordSet);
}
The compiler complains on the line with the return statement:
Error C2280 'CRecordset::CRecordset(const CRecordset &)': attempting to reference a deleted function
Can someone help me understand exactly what is happening here?
CRecordset's copy constructor has been explicitly marked asdeletedto prevent copyingCRecordsetobjects from one to the other.So, the function will have to return a new object by pointer and require the caller to
deletethe object when finished using it:Or better: