C++ operator and pointer question.plz help me

%=, >>=, <<=, &=, ^=, |=
what do these operators mean?
And what are the functions of these operators?

And also in the C++ tutorial provided in this website,
http://www.cplusplus.com/doc/tutorial/pointers/
in the [void pointer] section of this page,
i don't understand the program example demonstrated.
Why the parentheses should be placed like this ->> (char*)data / (int*)data ?
Why can't i place the parentheses like this ->> (char* data) /(int* data) ?

Sorry for the grammatical mistakes and thanks for the help :) .

[The program I mentioned above]
---------------------------------------------------
// increaser
#include <iostream>
using namespace std;

void increase (void* data, int psize)
{
if ( psize == sizeof(char) )
{ char* pchar; pchar=(char*)data; ++(*pchar); }
else if (psize == sizeof(int) )
{ int* pint; pint=(int*)data; ++(*pint); }
}

int main ()
{
char a = 'x';
int b = 1602;
increase (&a,sizeof(a));
increase (&b,sizeof(b));
cout << a << ", " << b << endl;
return 0;
}
--------------------------------------------------



Last edited on
xiuuao wrote:
%=, >>=, <<=, &=, ^=, |=
what do these operators mean?
And what are the functions of these operators?

If X is one of the operators %, >>, <<, &, ^, | then writing a X= b; has the same meaning as a = a X b;.

xiuuao wrote:
i don't understand the program example demonstrated.
Why the parentheses should be placed like this ->> (char*)data / (int*)data ?
Why can't i place the parentheses like this ->> (char* data) /(int* data) ?

It's the way C-casts are written. The type that you want to cast to inside parentheses. Writing char* data declares a char pointer named data. Putting declarations inside parentheses is only allowed in some cases and is very different from a cast.

Last edited on
Thx a lot ,man:)
Check this out just scroll down
http://www.cplusplus.com/doc/tutorial/operators/
Bitwise Operators ( &, |, ^, ~, <<, >> )

Bitwise operators modify variables considering the bit patterns that represent the values they store.

operator asm equivalent description
& AND Bitwise AND
| OR Bitwise Inclusive OR
^ XOR Bitwise Exclusive OR
~ NOT Unary complement (bit inversion)
<< SHL Shift Left
>> SHR Shift Right
=================================================
As there are no examples in this section[Bitwise operators ]
not sure what the actual function of these operators are in C++ :(
~,>> and <<

I tested on my computer and still not know how and when to use it.
Are they just not common operators used in programming?
Bitwise operators are often used when you care about the bits of a variable and not necessary the numerical value they represent.

Read this: http://en.wikipedia.org/wiki/Bitwise_operators

Do you have any c++ book..I'm sure they are in there..if not u can always get an e book
Topic archived. No new replies allowed.