Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
This chapter is from the book

Q&A

Q: What other languages are available for the CLR that can be accessed using managed C++?

A: Right now, Microsoft is only creating and distributing Visual Basic, C#, and managed C++. However, Microsoft has published the CLR specifications for other companies to create compilers for other languages. Several companies have pledged support for the platform and have announced plans to bring out compilers for various other programming languages. One of the first announced was by a company bringing out a COBOL compiler for the CLR. Any and all languages compiled for the CLR should be able to create objects that you can access using managed C++, or that you can create components using managed C++ that these languages can access.

Q: In the unmanaged C++ client, why couldn't I put the _gc modifier on the managed class?

A: The managed class in the unmanaged client has to be accessible by the unmanaged code in the application. When a managed class is marked for garbage collection, it can't be accessed by any unmanaged code. The reverse situation is when you have a managed, garbage collected class accessing an unmanaged class. It seems that managed, garbage collected objects can reach outside the managed sandbox to access unmanaged objects. It's just that the garbage collected objects are located on the CLR managed heap, which can't be accessed from the outside. But objects on the managed CLR heap can use non-garbage collected pointers to access objects on the outside.

Exercise

Add a second method to your VB or C# component to return the tax rate for the specified category. Modify the managed C++ client to request and display the tax rate.

  • + Share This
  • 🔖 Save To Your Account