Ninjakreborn Posted January 24, 2009 Share Posted January 24, 2009 Sorry to be asking so many questions tonight (knee deep in studying). This'll be the last one I ask tonight. This one is a "Which is better syntax" question. string firstname; cout << "What is your first name?"; std::getline(std::cin, firstname); cin.ignore(); or string firstname; cout << "What is your first name?"; getline(cin, firstname); cin.ignore(); The difference here is the std::getline can be used whether the namespace is included or not. However the cin getline can't be called unless it is. Out of these two which is the best method to get use to. Using the std::funcname or just funcname. Which is best overall because this'll be what I model my overall syntax ideas from. Quote Link to comment https://forums.phpfreaks.com/topic/142214-solved-c-syntax-question/ Share on other sites More sharing options...
corbin Posted January 24, 2009 Share Posted January 24, 2009 You can use infinite namespaces, or you can use 0. The point of a namespace is kind of like a class in PHP. It separates code based. I generally go ahead and use the std namespace, but I don't usually use other ones at the same time. If you're using two namespaces and they have functions with the same name, the compiler/linker will flip out. So, to sum it up, I use the std namespace because I'm lazy and see no problems with it, but I generally avoid using other namespaces for 2 reasons: the std namespace is the namespace in which most of the functions I use reside, and I don't like to use multiple namespaces, just in case. I don't know if there's a 'standard' on namespaces though. Quote Link to comment https://forums.phpfreaks.com/topic/142214-solved-c-syntax-question/#findComment-745047 Share on other sites More sharing options...
Ninjakreborn Posted January 24, 2009 Author Share Posted January 24, 2009 Ah ok. That makes sense. thanks again for the feedback. Quote Link to comment https://forums.phpfreaks.com/topic/142214-solved-c-syntax-question/#findComment-745054 Share on other sites More sharing options...
corbin Posted January 24, 2009 Share Posted January 24, 2009 No problem ;p. Quote Link to comment https://forums.phpfreaks.com/topic/142214-solved-c-syntax-question/#findComment-745076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.