12

I've programming for a long time in C and in C#, I thought moving to C++ would be smooth...
anyway, I've seen the use of caret but I don't understand the meaning of it.

what's the different between:

std::string *st1;

to

String::string ^st2;

Thanks!

Clearer
  • 2,166
  • 23
  • 38
Roee Gavirel
  • 18,955
  • 12
  • 67
  • 94
  • possible duplicate of [What does the caret mean in C++/CLI?](http://stackoverflow.com/questions/202463/what-does-the-caret-mean-in-c-cli) – Hans Passant Jan 02 '12 at 13:24
  • 1
    @HansPassant, I saw the question you referring to. but they just say it's like a pointer. I know it's like that, I don't know what's the different between them. – Roee Gavirel Jan 03 '12 at 07:33

2 Answers2

17

The caret is specific to C++/CLI, Microsoft's .NET version of C++, where it is the managed equivalent of a pointer.

It is not actually part of standard C++, so unless you truly mean to use .NET, don't use it.

Community
  • 1
  • 1
Michael Madsen
  • 54,231
  • 8
  • 72
  • 83
2
String::string ^st2

is not a standard ANSI C++ syntax!

Gangnus
  • 24,044
  • 16
  • 90
  • 149