Topic: overload * for declaration / prohibit declaration of pointers
Author: mi@starlab.UUCP (Michael Hoennig)
Date: 18 Jun 92 07:04:28 GMT Raw View
Hi NetFolk,
are ther any thoughts about changing the meaning of operator* by use
in declaration? I would like to prohibit to declare pointers to some
of my classes, if I had overloaded the operator* for use in
implementation. Example:
class DatabaseLine;
class DatabaseLine* // a smart-pointer to a DatabaseLine / new syntax
{
...
DatabaseLine(::*) operator->(); // return a real pointer
DatabaseLine& operator*();
DatabaseLine* operator++();
DatabaseLine* operator--();
DatabaseLine* operator++(int);
DatabaseLine* operator--(int);
operator unsigned long (); // index in database or 0 if NULL-pointer
};
void EditLine( DatabaseLine &rLine );
int main()
{
Database aBase( "file.name.data" );
for ( DatabaseLine *pLine = aBase.First(); // declare a smart-pointer
pLine != 0;
pLine++ )
EditLine( *pLine );
}
I know about the problem to recognize that there are smart-pointers defined,
if the definition of these is out of scope like here:
class DatabaseLine;
struct I_use_a_wrong_pointer
{
DatabaseLine* pLine; // ooh!
...
};
Further ideas?
Adios
--
Michael Hoennig FAX: +49 40 230 859
StarDivision (StarLab HH) Phone: +49 40 230 856
Heidenkampsweg 44 uucp: ...!unido!starlab!mi
D-W-2000 Hamburg 1 domain: mi@starlab.uucp