views:

130

answers:

5

Possible duplicates
What is gcnew?
What does the caret mean in C++/CLI?
Difference between managed c++ and c++

I am a advanced C++ programmer with g++. But currently I am working on Visual C++ 2005 doing Windows Forms Application programming . But I am finding it hard with its new terminology. For e.g. instead of new it has gcnew and

String ^ kind of thing. Can someone explain what is ^, similar to pointer?

Can I make Visual C++ work in the same way as normal C++ like g++ compiler? I also heard something about managed C++. What is that?

+1  A: 

The gcnew and ^ values are managed C++ which is a different language to c++. You can use VS2005 as a normal C++ compiler by not using a project type from the CLR section of the new project window.

Patrick
Will I be able to do same Windows forms application (GUI) programming with that? Beacause Windows forms application appears under CLR.
avd
You can use non-managed code in managed project but you need to use the special syntax with winforms. If you do not want to use this special syntax, you should create a MFC project from the MFC part of the new project wizard.
Patrice Bernassola
Windows Forms is, by definition, not available without the CLR, since it's the standard CLR GUI system.
OregonGhost
You can use Windows Forms application code (i.e. .NET code, which can be C#, Visual Basic .NET, or the aformentioned C++/CLI) via "regular" C++, if you use MFC and its .NET interfacing classes. Read more at: http://msdn.microsoft.com/en-us/library/ahdd1h97%28VS.80%29.aspx
Jonas
... however, using the Windows Forms framework is not necessary to write GUI's in Windows and C++. That is only used by .NET applications, as said above. A typical C++ application in Visual Studio and MFC has its GUI simply built by the C++ form designer.
Jonas
My preference would be to write the GUI in C# and forget both MFC and the CLR. Interfacing between C# and C++ is a bit pants so ymmv.
Patrick
@OreghonGhost: Windows Forms is not part of the (standardized) Common Language Runtime (CLR). It's missing from Mono for that reason. It does _require_ a CLR, though.
MSalters
+1  A: 

gcnew and ^ are from new Visual C++ syntax. The new syntax is not part of the ISO/ANSI C++ standard, but is a set of extensions to C++ standardized under the Ecma C++/CLI Standard. You can to not use them if you do not want to. Here you could read more about Visual C++ extensions.

Kirill V. Lyadvinsky
A: 

Managed C++ is used for .Net development in the Common Language Runtime (CLR) of Microsoft. This special C++ syntax was created to allow C++ developper to come in the .Net community without learning a new language like C#.

You can use Visual C++ in the same way as g++ by creating a non-CLR project.

Patrice Bernassola
But I want to do Windows FOrms Application programming (coming under CLR). How to do that?
avd
Winforms are managed so you must use managed c++ to use them (event it is possible to use unmanaged c++ for non-GUI par of your application). It is not intended to create new project with managed c++. It first usage is to "translate" c++ program to .Net program.
Patrice Bernassola
No, WinForms can be used from any CLR language, not just C++/CLI.
Alex
+1  A: 

Windows Forms are .Net specific, so you need to use C++/CLI (That's "managed C++") if you want to do those.

However, I'm not sure you really want windows forms? You just want some kind of windowy GUI, right? If that's the case you can go with something like MFC or just native O/S calls, to create your GUI, or you could use a wrapper API like Qt

[EDIT] Just to clarify a bit :)

I also heard something about managed C++. What is that?

C++/CLI is the .Net implementation of C++. Here you can use both regular C++ and managed code. C++/CLI was Microsofts attempt to ease the learning curve for C++ developers to get into the managed framework, however, it's not used a lot these days, wo you'll probably have a hard time finding (m)any good tutorials. Visual C++ is just the name of the IDE, it has nothing to do with which kind of C++ you use. You can use Visual C++ just as you use g++, but if you wan't anything over a console app, you'll need to wire some GUI logic into your application. As said in my original answer, this can be done a number of ways.

If you are sure you want to use .Net, I recommend spending a day with C#, as it's really easy to learn if you got C++ experience, but judging from your question I don't think this is what you want :)

cwap
A: 

Note that Windows Forms are not the only way to make GUIs under Windows. You can use the regular Win32 API instead, if you want pure C (which you can wrap with C++ if you like).

If you do choose Windows Forms, then you have the option of using C#, VB.NET, or C++/CLI (Managed C++). You need not use C++/CLI, as seems to be your presumption.

Alex