I am trying to provide a c++ interface for a c library I just finished, and I want it to be possible to write
for (DBITable table = db.tables() ; table != NULL ; table++)
where db
is a class with a tables()
method that returns the DBITable
associated with it.
On compilation I get the following error with clang++
error: cannot increment value of type 'DBITable'
for (DBITable table = db.tables() ; table != NULL ; table++)
~~~~~^
This is how i have implemented the ++
operator overload method
DBITable
DBITable::operator++()
{
return next();
}
and it's declared in the DBITable
class as
public:
DBITable operator++();
the table != NULL
part worked as I expected by doing this
bool operator!=(void *)
{
// evaluate and get the value
return value;
}