In this context I believe it's a bit shift operator. So 1 << 0 is 1 and 1
<< 1 is 2.

As for the << operator in C++...

The operator appears in C++ as the bitshift operator too. However, C++
supports operator overloading. This means that for custom data types (I.e.
classes), one can define how certain operators (including arithmetic and
logical operators) behave. This is done in a similar way to defining member
functions of a class. For example, one could overload the multiplication
operator * for a class 'Matrix' to implement correct matrix multiplication.

One operator overload which pervades the C++ standard library is the
'stream insertion operator'. For input and output streams such as the
standard output cout, the bitshift operators (<<,>>) have been redefined to
allow you to pass data to/from the stream.

This is arguably an abuse of notation and in general such confusing use of
operator overloading would be discouraged. However, in this case it is
perhaps justified since it provides a very convenient and intuitive way of
passing large numbers of objects of varying types to a stream such as cout.

Hope this helps clear things up.

Alex
On 9 Jul 2015 1:27 am, "walt" <w41...@gmail.com> wrote:

> I'm trying to debug a gtk+ app so I'm trying to learn some basic gtk+
> and failing :(
>
> Can anyone splain to me what these lines mean:
>
> typedef enum
> {
>   G_CONNECT_AFTER       = 1 << 0,
>   G_CONNECT_SWAPPED     = 1 << 1
> } GConnectFlags;
>
> In particular I don't understand what the << operator is doing.
>
> When I was young << meant bitwise shift to the left.  When I got old
> and tried to learn c++ it was a way to print a string to the terminal.
>
> Any clues would be welcome.  <type slowly and use small words, please>
>
>
>
>

Reply via email to