Click to See Complete Forum and Search --> : I need help with STD's!
The Ghost Of Ille Pugil
09-25-2001, 09:21 AM
I just started my OOP with C++ class last night. We discussed (briefly) namespaces, and the fact that the instructor wants us to use namespace::function format, eg:
#include <iostream>
int main()
{
std::cout << "\nHello World!\n\n";
return 0;
}
should (and does) work just fine. The problem is, I don't get errors when not including the std:: part (which doesn't surprise me, it didn't seem required). I asked him about this and he suggested setting and ansi/strict flag. So I checked google today, and found a couple of flags, but am unable to test until I go home tonight from work. I found -fhonor-std and -ansi. Any ideas as to what flags/options I need to do to inforce the namespace::function format (we get marked down otherwise). Any and all help is appreciated.
ps: using slack 8.0 with gcc/g++ 2.95.3 (so sayeth slackware.com)
Dark Ninja
09-25-2001, 09:25 AM
...well...I'm not really all up-to-date on my C++ programming (it's been two years), but, isn't that just a waste of time (and pointless) to type:
std::cout << "\nHello World!\n\n";
You can get rid of the "std::" and the program will still work wonderfully.
Oh yeah, in your #include statement, you forgot the .h extension. It should read:
#include <iostream.h>
Anyway - don't know if I really answered your question, but, I was just wondering about that.
Dark Ninja
The Ghost Of Ille Pugil
09-25-2001, 09:31 AM
actually, it works with and without the .h in the include (at least for headers in the standard library - IIRC).
As far as the std:: thing, yeah, I think it's a waste of time, typing and space, but if I'm getting graded on it being there or not, I need it there.
Strike
09-25-2001, 10:27 AM
It's not really a waste of time, because it enforces namespaces and avoids name clashes. By default, the std namespace is brought into the "global" namespace. This means every function in the std namespace is valid for every namespace. You could accomplish the same thing by using using namespace std; in your code.
Also, the C++ way of including is without the .h's. Look at the files and you'll see that they are basically wrappers for the .h files.
The Ghost Of Ille Pugil
09-25-2001, 10:35 AM
That makes sense with the namespace thing, but what flags do I use to enforce the std::cin thing?
[ 25 September 2001: Message edited by: The Ghost Of Ille Pugil ]
inkedmn
09-25-2001, 11:34 AM
when i opened this thread, i expected to see something about the clap ;)
eXtremist
09-25-2001, 01:43 PM
I haven't touched C++ in a couple of months, but I think to enforce the use of namespaces, you must have use strict; in your program.
The Ghost Of Ille Pugil
09-26-2001, 04:57 PM
Thanks, but I was looking for a flag/option to give g++ on compile time. As in g++ -option. Any ideas?
and no, I do not have the clapper. :)
element-x
09-26-2001, 05:08 PM
I think he meant 'the clap' as in the sexually transmitted disease ...lol, I expected something similar to tell you the truth.
Space-Cadet
09-26-2001, 05:29 PM
I'm surprised nobody has said "Just use a condom"
Dark Ninja
09-26-2001, 06:59 PM
Ahhhhh...but a condom does not protect against STD's all the time. ;-)
A short program:
#include <iostream.h>
main()
{
con << CONDOM;
cin >> vagina;
cout << "Heh Heh Heh";
return baby;
}
Hmmmmmmm...okay...a little weird. But, hey, it wraps the whole discussion together.
Dark Ninja
BTW - I know there is no such statement as 'con' - I invented it. ;-)
napkin_stealer
09-26-2001, 07:16 PM
lol! :) too phunnie!
Strike
09-26-2001, 08:27 PM
You might try -nostdlib
The Ghost Of Ille Pugil
09-27-2001, 02:07 PM
thanks strike, i'll try that when I get home.
BTW, it was a vague reference to Austin Powers 2, :p