can i compile and run .cpp file in .net environment as in VC++

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am confused and dont know how to use .net environment to work with C++. but i am just not sure whether it's possible or not. Can anyone tell me, pls?
 
Mon said:
I am confused and dont know how to use .net
environment to work with C++. but i am just
not sure whether it's possible or not.
Can anyone tell me, pls?

To which environment are you referring - the IDE's or the runtime's?

If you are asking can you use what Microsoft calls "Managed Extensions for
C++" so that you can use the C++ language to build applications which run
under the control of the .Net runtime (i.e. the Common Language Runtime or
CLR) the answer is yes.

Take this program

#include <iostream>
using namespace std;

int main()
{
cout << "Hello, world" << endl;

return 0;
}

and compile it with the command

cl /EHsc /clr hello.cpp

and you get an executable which runs under .Net.

Of course, you can arrive at the same place using (in some sense less
standard) C++:

#using <mscorlib.dll>
using namespace System;

int main()
{
Console::WriteLine(S"Hello, world.");

return 0;
}

Regards,
Will
 
Back
Top