![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#31 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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";
}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 |
|
|
|
|
|
#32 |
|
Hobbyist Programmer
|
no need to say sorry!!!
ur explanation is cool thanx!
__________________
From the bottom of the stone steps... ...i'm calling still. |
|
|
|
|
|
#33 | |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#34 |
|
Programming Guru
![]() |
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 |
|
|
|
|
|
#35 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#36 |
|
Programmer
Join Date: May 2005
Posts: 41
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#37 |
|
Programmer
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#38 | |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
Quote:
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
|
#39 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
|
|
|
|
|
|
|
#40 |
|
Programmer
Join Date: Aug 2005
Location: Norway
Posts: 56
Rep Power: 0
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|