I've just returned to C++ for a game related project for Windows 8/RT after many years of absence in favor of C#.
Working with the generated Game Project Skeleton I've stumbled upon method signatures like the one below. Could anyone enlighten me what's the ^ is supposed to do?
Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
Variable is basically nothing but the name of a memory location that we use for storing data. We can change the value of a variable in C or any other language, and we can also reuse it multiple times.
Variables are containers for storing data values. In C, there are different types of variables (defined with different keywords), for example: int - stores integers (whole numbers), without decimals, such as 123 or -123. float - stores floating point numbers, with decimals, such as 19.99 or -19.99.
The convention in C is has generally been to declare all such local variables at the top of a function; this is different from the convention in C++ or Java, which encourage variables to be declared when they are first used.
In C++/CX, a T^
is a handle to a T
object. It's effectively a smart pointer that owns a reference to the pointed-to object, with some extra bonus features provided by the compiler.
You can find out all about hats in the article, "Types That Wear Hats."
Apparently it's called the handle-to-object operator.
The handle-to-object operator ^ is known as a "hat" and is fundamentally a C++ smart pointer. The memory it points to is automatically destroyed when the last hat goes out of scope or is explicitly set to nullptr.
According to: https://msdn.microsoft.com/en-us/library/hh699870.aspx. (From the "Memory Management" section of that page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With