Using the ^ operator in visual C ++

I do Visual C ++ programming, I created a CLR console application. I noticed that String arrays should be declared as String ^, not String []. What is the use of ^? And why is it used instead of []? And is this replacement limited to CLR applications only? Here is the line of code and the error:

array<String[]>[] abc; 

the generated errors were

error C2143: syntax error: missing ';' before '['

error C2146: syntax error: missing ';' before identifier 'abc'

eror C2065: 'abc': undeclared identifier

+7
source share
1 answer

An emphasis outline means that the object is a managed pointer, it will be automatically collected by the garbage collector - you do not need to do this implicitly. Please see this article to understand how arrays work in C ++ / CLI.

In your case:

 array<String^> ^abc; 

And is this replacement limited to CLR applications only?

Yes.

+12
source

All Articles