Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 2nd, 2005, 1:38 PM   #31
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Let's just back off to your original post, for a second.
#include <iostream.h>
#include <string.h>
int main()
{
    std::string quote;
    std::cin.getline(quote,50);
    if(quote=="The one and the only one...darkone.")
    std::cout<<"\a";
}
Don't use the .h versions of the include files. They were made for backward compatibility and have been deprecated.

Namespaces are provided so that you may distinguish between two entities with the same name. Possibly you know more than one person named Bob. There's geek::Bob and there's father::Bob, your priest. The portion preceding the "::" is the qualifier that allows you distinguish. You have defined "quote" as being of type "string". There may well be more than one defined type, "string". Consequently, you have said, it's a std::string. If you think you're going to be hanging around church and no geeks will be present, you can just make a mental note: "using namespace church", and not have to say father::Bob, just Bob. You just want to be careful where you declare which namespace you're using. If you put, "using namespace church" on a sign on your back and go to a geek's convention, you aren't going to be able to get geek::Bob's attention or else, if father::Bob is there, you may get a conflict when they BOTH answer you.

There are also more than one "getline" function. The appropriate one will be called if you include the correct files and if you express the parameters correctly.

If you are still having difficulties getting your program to run, please repost your CURRENT code and the error messages you are CURRENTLY getting. Sorry to confuse you with too many caveats and technical points for the small program you have presented.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 2nd, 2005, 1:45 PM   #32
darkone916
Hobbyist Programmer
 
darkone916's Avatar
 
Join Date: Jul 2005
Location: Oman
Posts: 125
Rep Power: 4 darkone916 is on a distinguished road
Send a message via MSN to darkone916
no need to say sorry!!!
ur explanation is cool thanx!
__________________
From the bottom of the stone steps...
...i'm calling still.
darkone916 is offline   Reply With Quote
Old Aug 2nd, 2005, 2:37 PM   #33
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
By the way you have to admit "gimp" is a horrible name for a piece of software.
Heh, totally. Anyone who I mention it to who has watched Pulp Fiction gets a little scared of me..
Cerulean is offline   Reply With Quote
Old Aug 3rd, 2005, 2:14 AM   #34
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
Gimp = male sex slave.

The gimp in pulp fiction just sorta stands there :/
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Aug 3rd, 2005, 5:59 AM   #35
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
And all this time I thought, "average man = male sex slave" .
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 4th, 2005, 12:19 PM   #36
MrSmiley
Programmer
 
MrSmiley's Avatar
 
Join Date: May 2005
Posts: 41
Rep Power: 0 MrSmiley is on a distinguished road
InfoGeek, props... I have a question, it's just a rumor I heard, but doesn't "using namespace xyz;" bog down the ram a little more than "using xyz:abc;"? i.e. "using namspace std;" uses more ram than "using std::cout;". Just a rumour I picked up one day of trolling the internet.
MrSmiley is offline   Reply With Quote
Old Aug 4th, 2005, 12:46 PM   #37
prolog
Programmer
 
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4 prolog is on a distinguished road
The only thing i could imagine where a bigger amount of ram is taken by using the using-directive is during compilation as you import all symbols of that namespace.
__________________
-= C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do succeed, you will blow away your whole leg. =- Bjarne Stroustrup
prolog is offline   Reply With Quote
Old Aug 5th, 2005, 6:56 AM   #38
InfoGeek
Professional Programmer
 
InfoGeek's Avatar
 
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4 InfoGeek is on a distinguished road
Quote:
Originally Posted by MrSmiley
InfoGeek, props... I have a question, it's just a rumor I heard, but doesn't "using namespace xyz;" bog down the ram a little more than "using xyz:abc;"? i.e. "using namspace std;" uses more ram than "using std::cout;". Just a rumour I picked up one day of trolling the internet.
I think prolog answered that...
__________________
PFO - My daily dose of technology.
InfoGeek is offline   Reply With Quote
Old Aug 7th, 2005, 10:46 AM   #39
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Quote:
Originally Posted by Cerulean
Heh, totally. Anyone who I mention it to who has watched Pulp Fiction gets a little scared of me..
Every time I hear the name it reminds me of that movie. I can't use it any more. :p
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 8th, 2005, 3:15 AM   #40
mikaoj
Programmer
 
mikaoj's Avatar
 
Join Date: Aug 2005
Location: Norway
Posts: 56
Rep Power: 0 mikaoj is an unknown quantity at this point
Many programmers use std::cin, etc.
Also many from Norway use it.
It must be easier to just write using namespace std; and forget the std::cin.
Why are all doing this?
__________________
Heh.
mikaoj is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:31 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC