Click to See Complete Forum and Search --> : System::String^ question


Programmer127
January 3rd, 2007, 10:08 PM
I know the following line of code works to define a string, but what does the ^ do, and how come this declaration will not work without it?
------------------------------------------------------------------------------------------------
System::String^ something = "hello";
------------------------------------------------------------------------------------------------
I really appreciate any help, Thanks in advance!

sureshkumarct
January 3rd, 2007, 11:22 PM
You could check the following links:

http://www.asp101.com/articles/yuri/strings/default.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemStringClasstopic.asp

I have seen this question posted on some forum...Please check the linkand reply if it helped or not...

Marc G
January 4th, 2007, 09:21 AM
[ moved thread ]

Zaccheus
January 4th, 2007, 11:21 AM
I know the following line of code works to define a string, but what does the ^ do, and how come this declaration will not work without it?
------------------------------------------------------------------------------------------------
System::String^ something = "hello";
------------------------------------------------------------------------------------------------
I really appreciate any help, Thanks in advance!

The ^ simply states that 'something' is a garbage collected pointer.

Programmer127
January 4th, 2007, 07:28 PM
Sureshkumarct, thanks for the links, that taught me a little more about strings, but I am too much of a beginner to have gotten everything out of the articles. Zaccheus, you said:
------------------------------------------------------------------------------------------------
"The ^ simply states that 'something' is a garbage collected pointer."
------------------------------------------------------------------------------------------------
What is a garbage collected pointer? Is that what the "^" symbol is always used for? Thanks for the help, I just began learning C++, and read a book on it, but the ^ symbol must be specific to vc++, because it was not in the book. Anyways, I have been confused by it for a while, and I appreciate you guys clarifying it for me.

Marc G
January 5th, 2007, 04:22 AM
No, the ^ symbol is specific to Managed C++, not to the standard C++.
The garbage collector in managed C++ will cleanup unused objects just like it is done in Java.

Programmer127
January 6th, 2007, 06:51 PM
Okay, thanks for the help!