This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
egcs-1.1.2: overloaded ++ operator
- To: egcs mailing list <egcs at egcs dot cygnus dot com>
- Subject: egcs-1.1.2: overloaded ++ operator
- From: Brendan Simon <bsimon at ctam dot com dot au>
- Date: Tue, 23 Nov 1999 15:56:09 +1100
- Organization: CTAM Pty Ltd
- Reply-To: bsimon at ctam dot com dot au
I have a unsigned 64 bit integer object called U64. The following code
example gives the following error.
// **** SAMPLE CODE ****
#include <iostream>
typedef unsigned long long UINT64;
union U64
{
public :
U64();
U64( const UINT64 newValue );
operator UINT64 ();
U64 & operator ++ ();
#if 0
U64 & operator ++ ( const int value );
#endif
private :
UINT64 u64;
};
inline U64::U64()
{
u64 = 0;
}
inline U64::U64( const UINT64 newValue )
{
u64 = newValue;
}
inline U64::operator UINT64 ()
{
return u64;
}
inline U64 & U64::operator ++ ()
{
u64++;
return *this;
}
#if 0
inline U64 & U64::operator ++ ( const int value )
{
u64++;
return *this;
}
#endif
int main( int argc, char * argv[] )
{
U64 var;
var = argc;
cout << "var = " << var << endl;
var++;
cout << "var = " << var << endl;
return 0;
}
**** ERROR MESSAGE ****
u64.cpp: In function `int main(int, char **)':
u64.cpp:66: warning: no `operator ++ (int)' declared for postfix `++',
trying prefix operator instead
u64.cpp:66: no match for `++U64 &'
If I replace the "#if 0" with "#if 1" then every thing works OK. From
the C++ standard I should only need the "operator ++ ();" declaration.
Is this a problem with egcs-1.1.2 and does any one know if it works
properly in gcc-2.95.x ? I have not had a chance to download gcc-2.95.x
sources and build the compiler.
Thanks,
Brendan Simon.