Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of ^ operator in visual c++

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

array<String[]>[] abc;

the errors generated were

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

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

eror C2065: 'abc' : undeclared identifier

like image 767
Haris Avatar asked May 14 '12 05:05

Haris


People also ask

What is the use of ?? operator in C?

?? Operator (C# Reference) The ?? operator is called the null-coalescing operator and is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.

What are arithmetic and logical operators in C++?

For example, arithmetic operators perform arithmetic operations with operands of built-in numeric types and Boolean logical operators perform logical operations with the bool operands. A user-defined type can overload certain operators to define the corresponding behavior for the operands of that type.

What are the operators supported by the built-in types in C?

C# provides a number of operators supported by the built-in types. For example, arithmetic operators perform arithmetic operations with numeric operands and Boolean logical operators perform logical operations with the bool operands.

What is the use of assignment operator in C?

C# Assignment Operators Assignment operators are used to assign values to variables. In the example below, we use the assignment operator (=) to assign the value 10 to a variable called x:


1 Answers

The circumflex accent means that the object is a managed pointer,it'll be automatically collected by the Garbage Collector - you don't need to do this implicitly. Please take a look at this article to understand how arrays work in C++/CLI.

In your case:

array<String^> ^abc;

And is this substitution limited only to CLR applications?

Yes.

like image 173
Ceramic Pot Avatar answered Oct 11 '22 21:10

Ceramic Pot