I need your help, please (Visual C++ 2008)

正在查看此主题的用户

Stonewall382

Knight at Arms
I'm programming in Visual C++ 2008 Express Edition, and I cannot for the life of me declare a string.  I don't need to declare a string class, or anything like that, I just need to be able to declare a damned string, like people've been able to since time immemorable (or, at least since C++ came out).
I'm pretty sure my problem is that I can't use the namespace "std."  I type 'using namespace std' right below the last include statement, and I get an error telling me that there is no namespace with that name.  What gives?

I'd like to use Java to do this program, but I need to be able to compile into an exe, or into an application, and the advice given on messageboards and such make it seem like a ***** to do.
 
So...  why not just use C++, or C# (which is supposed to be like Java)?

I think Microsoft even has a translator thingamabob that will transform Java code into executables, but I don't know if it commercial or how well it works.
 
Is there a difference between Visual C++ and ... normal C++?  I thought it was just a difference of development environment.

At any rate, I've gone back to good ole Java, using sweet, wonderful NetBeans, so it's all good.  Thank you.
 
Have you got an #import <string> at the top? I think BASIC had a better idea of just prefixing strings with $ signs :razz:

Stonewall382 说:
I'd like to use Java to do this program, but I need to be able to compile into an exe, or into an application, and the advice given on messageboards and such make it seem like a ***** to do.
As long as the user has the Java runtime (on any OS that has such a thing), a .jar file works as an excecutable. Being interpreted, it's (well, slightly) slower than a compiled language like C++.
 
Cymro 说:
As long as the user has the Java runtime (on any OS that has such a thing), a .jar file works as an excecutable. Being interpreted, it's (well, slightly) slower than a compiled language like C++.

To be precise, Java can be interpreted, but anything that runs for more than a split-second is compiled at run time and executes on a virtual machine, which is not really much different in speed compared to machine code.  Whereas, for example, Matlab and Python are interpreted (last I checked).  The main speed differences between Java and C come from the fact that Java only supports single-dimensional arrays, you can't explicitly allocate memory without creating an object, you can't manually align things with cache lines (not that I would ever bother), accessing functions and data generally require more chained dereferences, array references will always implicitly check array bounds...  and a few other things.  It sounds like it would be really slow, but for some reason it isn't.  Probably because modern CPUs typically have idle execution units, and much of Java's overhead can be parallelized with actual work.
 
后退
顶部 底部