# c++ : vs ::

**URL:** <https://forums.unrealengine.com/t/c-vs/14112>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [October 27, 2014, 4:21pm UTC](https://forums.unrealengine.com/t/c-vs/14112 "2014-10-27T16:21:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_a624771d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a624771d](https://forums.unrealengine.com/u/anonymous_user_a624771d)\
**Post date:** [October 27, 2014, 4:21pm UTC](https://forums.unrealengine.com/t/c-vs/14112/1 "2014-10-27T16:21:28Z")

</div>

I’m learning c++ and doing the tutorial at [http://www.learncpp.com/](http://www.learncpp.com/)

But as I’m going along I cant seem to figure out what :: and : mean. (I see them used all over in the code and google comes up short).

---

<div class="post-metadata">

**Author:** ![jCoder](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jCoder](https://forums.unrealengine.com/u/jCoder)\
**Post date:** [October 27, 2014, 4:34pm UTC](https://forums.unrealengine.com/t/c-vs/14112/2 "2014-10-27T16:34:05Z")

</div>

:: (double colon) is the [scope resolution operator](http://msdn.microsoft.com/en-us/library/b451xz31.aspx). For example, when you see std::string, std is a namepsace and string is a symbol in the namespace std.

: (Single colon) is used in two places. The [comparison operator (?🙂](http://msdn.microsoft.com/en-us/library/e4213hs1.aspx)and following access control keywords (public, protected and private) in class/struct declarations.

---

<div class="post-metadata">

**Author:** ![SolitaryTurian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SolitaryTurian](https://forums.unrealengine.com/u/SolitaryTurian)\
**Post date:** [March 10, 2015, 10:45pm UTC](https://forums.unrealengine.com/t/c-vs/14112/3 "2015-03-10T22:45:59Z")

</div>

I’m terribly sorry for bringing this thread back from the dead, but there’s another use case for single colon that jCoder didn’t address. In the header files, you can often see stuff like this:

```auto

UPROPERTY(BlueprintReadWrite, Category=Actor)
uint32 bAutoDestroyWhenFinished:1;

```

I still haven’t figured out what that :1 at the end of the variable name means. Can anyone elaborate on this?

Thanks a lot in advance!

---

<div class="post-metadata">

**Author:** ![Zhi\_Kang\_Shao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zhi\_Kang\_Shao](https://forums.unrealengine.com/u/Zhi_Kang_Shao)\
**Post date:** [March 10, 2015, 10:56pm UTC](https://forums.unrealengine.com/t/c-vs/14112/4 "2015-03-10T22:56:59Z")

</div>

Not sure how its called, but you use it to specify how many bits you’re actually using allowing the compiler to optimize memory usage by packing variables together. In this case you’re telling the compiler you’re using only 1 bit. If you declare 8 variables like that, without other typed variables inbetween, then those 8 variables together only take up 8 bits instead of 8 \* 32 bits.

---

<div class="post-metadata">

**Author:** ![hyperdr1ve](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hyperdr1ve](https://forums.unrealengine.com/u/hyperdr1ve)\
**Post date:** [March 10, 2015, 10:59pm UTC](https://forums.unrealengine.com/t/c-vs/14112/5 "2015-03-10T22:59:46Z")

</div>

> [@ThomasKasene;243610](#):
>
> I’m terribly sorry for bringing this thread back from the dead, but there’s another use case for single colon that jCoder didn’t address. In the header files, you can often see stuff like this:
> 
> ```auto
> 
> UPROPERTY(BlueprintReadWrite, Category=Actor)
> uint32 bAutoDestroyWhenFinished:1;
> 
> ```
> 
> I still haven’t figured out what that :1 at the end of the variable name means. Can anyone elaborate on this?
> 
> Thanks a lot in advance!

I don’t know the proper name, but I’ve always called this a bit field operator. It allows you to define the number of bits that the variable will occupy. So above, even though a uint32 is defined as a 32-bit unsigned integer, it will only utilize 1 bit of that instead of 32.

You see this type of programming a lot in embedded systems where you often need to pad structs to occupy an exact number of bits. The above example is essentially turning a uint32 into a boolean. I’m not sure what the advantage is without seeing the context, maybe it was easier to set boolean values based on some number calculations… or maybe the original author is following their own style.

---

<div class="post-metadata">

**Author:** ![SolitaryTurian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SolitaryTurian](https://forums.unrealengine.com/u/SolitaryTurian)\
**Post date:** [March 10, 2015, 11:04pm UTC](https://forums.unrealengine.com/t/c-vs/14112/6 "2015-03-10T23:04:24Z")

</div>

Aha yeah, that makes sense. I think that clears that up. Thanks a lot for the speedy replies, you two 🙂

EDIT: And for reference, that code was just an example I had handy, from AActor, I believe.

---

<div class="post-metadata">

**Author:** ![Mhousse1247](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mhousse1247](https://forums.unrealengine.com/u/Mhousse1247)\
**Post date:** [March 10, 2015, 11:10pm UTC](https://forums.unrealengine.com/t/c-vs/14112/7 "2015-03-10T23:10:48Z")

</div>

it’s called Bbtfields

> **[The C Book — Bitfields](https://publications.gbdirect.co.uk/c_book/chapter6/bitfields.html)**
