Stop Microsoft
Miscellaneous => Programming & Networking => Topic started by: Faust on 11 May 2003, 12:04
-
OK now I'm learning C++ as well as eiffel.
Typing std::cout all the time is annoying, and according to the book I'm using I should be able to avoid this by putting "using std::cout;" or "using namespace std;" at the top of my program just below "int main()" and the "{". But when I go to do g++ program.cpp I get a compiler error -
Is this just because I am using an old compiler? It's on my Universities Solaris boxes.
Heres the actual (no laughing this is my first day!) file:
edit:everything bar the "using" lines is a copy of another file, cout_easy.cpp with the "std::" parts removed, and that compiled fine.
Also is there a nice way to compile it and have the binary come out with the same name as the source file minus the ".cpp"? It gets annoying having to do "mv a.out [new_name]" all the time.
[ May 11, 2003: Message edited by: Faust ]
-
I hate to break it to you, but that code compiled fine on my computer.
:confused:
-
Damn old as Solaris boxes then. Bah! When will the computer sciences division invest in a newer gcc/g++?
Thanks Linux User, now I know it's not my fault. ;)
-
Weeaaak. What version of gcc do those computers have? (type g++ --version)
I just sshed to my univ's solaris mainframe and compiled that code just fine on it too. And I looked hard at it, and I can't figure out what the hell is wrong. Very odd.
-
quote:
Also is there a nice way to compile it and have the binary come out with the same name as the source file minus the ".cpp"? It gets annoying having to do "mv a.out [new_name]" all the time.
sure.
> g++ -o somename somename.cc
-
quote:
Weeaaak. What version of gcc do those computers have? (type g++ --version)
u2564793@iwaki g++ --version
2.8.1
u2564793@iwaki
-
I think there's no support for namespaces in that version of g++ (it's about 5 years old). Get your sys admins to upgrade.
-
probably doesnt support it, but try 'using namespace std;' above and outside the main function.
if that doesnt work, just try omitting all the using statements and try using cout without std:: attached to it. Behind the standards mebbe?