function trouble, need alittle help understanding

Started by
12 comments, last by germpest 21 years, 2 months ago
In reference to the std:: vs using namespace std;
with the using namespace std, you are telling that compiler to look in the std namespace for functions. By using std:: you are stated to look in the std namespace for this specific function.

BoyWunder
Advertisement
You could have also put the ''std::'' lines after your include statement, then just used cin and cout. Like this:

#include <iostream>

using std::cin;
using std::cout;

int main()
int age;
{

cin >> "Enter your age: " >> age;
cout << "\nYour age is: " << age;
return 0;

}
awesome, I didn''t know you could use
using std::cin & using std::cout

that''s cool.

could you do it like this?

using std::cin, std::cout;

quote:Original post by germpest
could you do it like this?
using std::cin, std::cout;


Try it. If it doesn''t compile, you can''t do it. If it does compile, you can.

I don''t like "can I do this?" questions very much, because it''s often simply a matter of making a test application, which you can usually do in a few minutes.

I''ll tell you anyway though, just cause I''m in that kind of mood: No. Don''t believe me? Try it

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

This topic is closed to new replies.

Advertisement