'^' syntax in C++ under .NET Framework

A

abhishekkarnik

I was going over MSDN to find a way to enumerate files using C++ under
the .NEt framework. I
came across some syntax that looks like:
DirectoryInfo^ di = gcnew DirectoryInfo("..\\GA\\Files");
array<FileInfo^>^fiArr = di->GetFiles();
Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
while ( myEnum->MoveNext() )
{
FileInfo^ fri = safe_cast<FileInfo^>(myEnum->Current);
Console::WriteLine( fri->Name );
}

My question is, what are all the "^" and if there is any documentation
anyone knows off so that I can read about it

regards,
Abhi
 
V

Victor Bazarov

I was going over MSDN to find a way to enumerate files using C++ under
the .NEt framework. I
came across some syntax that looks like:
DirectoryInfo^ di = gcnew DirectoryInfo("..\\GA\\Files");
array<FileInfo^>^fiArr = di->GetFiles();
Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
while ( myEnum->MoveNext() )
{
FileInfo^ fri = safe_cast<FileInfo^>(myEnum->Current);
Console::WriteLine( fri->Name );
}

My question is, what are all the "^" and if there is any documentation
anyone knows off so that I can read about it

I believe that's C++/CLI (or "Managed C++"). It's not C++. Microsoft
decided to confuse the entire programming world with their new names,
especially since they decided to drop the "/CLI" notation in most of
their documentation, which is in itself an outrage, AFAIAC. Please ask
in a microsoft.public.* newsgroup about the syntax of their language.

V
 
A

alexandru.lz

I believe that's C++/CLI (or "Managed C++"). It's not C++.

You are correct. It's one of Microsoft's additions to C++.

If I remember well, '^' represents a managed pointer, but don't take
it for granted, my single contact with managed C++ was some year and
half ago and I hated it.

The syntax additions are described in the MSDN docs.
 
S

Sarath

I was going over MSDN to find a way to enumerate files using C++ under
the .NEt framework. I
came across some syntax that looks like:
DirectoryInfo^ di = gcnew DirectoryInfo("..\\GA\\Files");
array<FileInfo^>^fiArr = di->GetFiles();
Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
while ( myEnum->MoveNext() )
{
FileInfo^ fri = safe_cast<FileInfo^>(myEnum->Current);
Console::WriteLine( fri->Name );
}

My question is, what are all the "^" and if there is any documentation
anyone knows off so that I can read about it

regards,
Abhi

Actually "^" is called handle. It's used to give handle (like pointer)
to the object in managed heap (garbage collected memory allocation).
It is used in context with gcnew(garbage collected new)
http://msdn2.microsoft.com/en-us/library/yk97tc08(VS.80).aspx

Surely this question is not supposed to deal with this forums. Please
contact any microsoft newsgroups for more info.

Regards,
Sarath
http://sarathc.wordpress.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top