Topic: Type of return value for logical operators ?
Author: jimad@microsoft.com (Jim Adcock)
Date: Wed, 3 Nov 1993 18:54:18 GMT Raw View
In article <2b4i0h$6is@wuecl.wustl.edu> abed@saturn.wustl.edu writes:
|I have overloaded the logical operators < > <= || && etc
|for one of my classes. I have been into the habit of declaring
|everything that is nonnegative as (size_t). But the actual
|logical operators in C++ returns int. So what should I do...
Probably a bad habit. The intent of size_t is to specify the
'native' size of unsigned thing used to specify the size of objects
on a particular system. On most 32-bit systems this will be 32-bits,
16-bits on 16-bit system -- but not always. Whereas logical operators
do by definition return int. Suggest you use each as intended in
the language.
Author: abed@saturn.wustl.edu (Abed M. Hammoud)
Date: 2 Nov 1993 02:52:01 GMT Raw View
I hope I wont get flamed for this question....
I have overloaded the logical operators < > <= || && etc
for one of my classes. I have been into the habit of declaring
everything that is nonnegative as (size_t). But the actual
logical operators in C++ returns int. So what should I do...
I cannot decide....does it really matter. Note that the result
of mu logical operator is an array of zeros and ones only.
So for example I say:
array<float> A(5, 5), B(5, 5);
:
:
array<size_t> C = A < B;
then C[i][j] will be the result of (A[i][j] < B[i][j]).
So what do you think,
Thanks,
+-------------------------------------------------+-----------------------+
|Abed M. Hammoud (KB0INX) | abed@saturn.wustl.edu |
|Washington University. | Office: |
|Electronic Systems & Signals Research Laboratory.| -Voice:(314) 935-7547 |
|Department of Electrical/Biomedical Engineering. | -FAX: (314) 935-4842 |
|Campus Box 1161, One Brookings Drive. | |
|St. Louis, MO , 63130 USA | |
+-------------------------------------------------+-----------------------+