Sign in to follow this  
Spa8nky

[C++] Can't use System namespace in Visual C++ 2008

Recommended Posts

Sorry about this but I can't figure out why the following line does not work in Visual C++ 2008:
using namespace System;
I keep getting the following error: error C2871: 'System' : a namespace with this name does not exist What have I done wrong here? Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by Spa8nky
error C2871: 'System' : a namespace with this name does not exist

What have I done wrong here?

Exactly what the error message says: that namespace does not exist (or at the very least, it can't find it in the current scope).
Did you forget to include a header file, or are you confusing managed with unmanaged code?

Share this post


Link to post
Share on other sites
Quote:
Original post by Spa8nky
Sorry about this but I can't figure out why the following line does not work in Visual C++ 2008


Visual C++ 2008 is your IDE.

What programming language do you think you are using?

If you think you are using C++: C++ does not have a 'System' namespace by default. It does have a 'std' namespace for its standard library.

Share this post


Link to post
Share on other sites
Are you attempting to create a C++/CLI (sometimes incorrectly called "managed C++") application? If so, it appears as though you picked the wrong options during project generation (choose a CLR project).

Share this post


Link to post
Share on other sites
Ah I see. I thought I was being a bit stupid here.

How can I use the equivalent of Console::Writeline (Console.WriteLine [C#]) in C++.

http://msdn.microsoft.com/en-us/library/system.console.aspx

Is there a good way to display messages in an output window like the console?

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this