Hi, Noorez Kassam,
I would try first "const T&":
bool basic_bignumber<T, __low_value, __high_value>::operator>( const T&
test )
(I cannot test it now)
I think there is something wrong with the prototype of the
compare-operator. The compiler gets
no match in cases of parameter-types-incompatibilities. The "name" of
the compare method is correct,
that's clear: "operator>".
best regards,
Wolf Peuker
Noorez Kassam schrieb:
> I'm having trouble using a template that i have.
> I'm making a template class, and overloaded the comparison operator >.
> The function below should compare the type of my class, with the
> template parameter T. I tested it with int as the type for the
> template and attempted to this comparison
>
> basic_bignumber<int,0,9> value(15);
> if( value > 3 )...
> but the compiler complained and said there was no match for operator>
> for value>3. Anyone have any ideas with whats wrong?
>
> template< typename T, int __low_value, int __high_value >
> bool basic_bignumber<T, __low_value, __high_value>::operator>( T& test )
> {
> basic_bignumber< T, __low_value, __high_value > compare( test );
>
> int pos1 = 0, pos2 = 0;
>
> for( int i = 0; i < value_size; i++ )
> {
> if( value[ i ] == 0 ) continue;
> pos1 = i;
> break;
> }
>
> for( int i = 0; i < compare.value_size; i++ )
> {
> if( compare.value[ i ] == 0 ) continue;
> pos2 = i;
> break;
> }
>
> if( pos1 == 0 && pos2 == 0 ) return false; //all were zero's
>
> else if( pos1 != 0 && pos2 == 0 ) return true; //if this had something
> //while the other
> didn't
>
> else if ( pos1 == 0 && pos2 != 0 ) return false; //if this didn't have
> //anything, while the
> other
> //did
>
> //if the the total value_size - (pos+1) is then compare, there
> //are more values, so this would be greater...
> if( value_size-(pos1+1) > compare.value_size-(pos2+1) ) return true;
>
> //so if both the pos's are the same and the value's are both of
> //the same size...check each individual digit...
> bool greater = true;
>
> for( int i = pos1; i < value_size; i++ )
> {
> if( value[ i ] < compare.value[ i ] ) greater = false;
> else continue;
> }
>
> return greater;
> }
>
> _________________________________________________________________
> Take advantage of powerful junk e-mail filters built on patented
> Microsoft® SmartScreen Technology.
> http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
> Start enjoying all the benefits of MSN® Premium right now and get the
> first two months FREE*.
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|