3

Possible Duplicate:
What does the caret mean in C++/CLI?

System::String is a class. What does the additional caret mean?

System::String^ productString = L"";

Has anyone seen this before? I can't find anything in Stroustrop on this one.

Community
  • 1
  • 1
Kieveli
  • 10,944
  • 6
  • 56
  • 81
  • 4
    You can't find anything because this is not C++ code. http://en.wikipedia.org/wiki/C%2B%2B/CLI – UncleBens Nov 09 '10 at 15:48
  • 1
    Removed C++ tag because this is not C++. – Billy ONeal Nov 09 '10 at 15:49
  • 1
    The C++ tag being missing is why I couldn't find other matching answers before. – Kieveli Nov 12 '10 at 18:55
  • 3
    It's not exactly a duplicate. This question asks what it means **in C++**. Of course the answer is "nothing, and what you're looking at isn't actually C++", but as @Kieveli points out, if you don't already know the answer, then you're going to ask *this* question, not "what does it mean in C++/CLI" – jalf Nov 12 '10 at 19:03
  • Nice =) I earned the popular question badge on a question with 0 up-votes. That should be a new kind of badge. – Kieveli Oct 28 '13 at 18:06

5 Answers5

9

This is Microsoft's C++/CLI. The ^ operator is used for accessing .NET reference types. It means sort of a "handle", and the syntax is ClassName^ instead of ClassName*.

Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
6

It's not really C++ but C++/CLI (a C++ look-alike language targeting the Common Language Interface)

icecrime
  • 74,451
  • 13
  • 99
  • 111
6

What does 'System::String^' mean in C++?

Nothing! Because it isn't C++, its C++/CLI. productString is a handle ^ to ""

Prasoon Saurav
  • 91,295
  • 49
  • 239
  • 345
3

This syntax is specific to C++/CLI, Microsoft's managed version of C++.

Avoid this unless you absolutely must have it for interop with native C++ code. If you are writing managed code, use C# - native code, C++.

Steve Townsend
  • 53,498
  • 9
  • 91
  • 140
2

It is not a standard C++, it's C++/CLI where System::String^ means a handle to System::String.

vitaut
  • 49,672
  • 25
  • 199
  • 336