| rero92 (1) | |
|
guys I need your help I can't understand how I to use std namespace I hope to help me in fastest time | |
|
|
|
| JLBorges (1754) | |||
|
Use a reasonably current C++ implementation. Use standard (non-deprecated) C++ headers. http://en.cppreference.com/w/cpp/header Prefix names in the library with std::For instance,
| |||
|
|
|||
| kaidto (12) | |||||
whenever you start coding
putting using namespace std;inside your code will allow you to avoid using the prefix std::and access directly to the namespace variables and methods. this:
will compile exactly as the above. | |||||
|
|
|||||
| kaidto (12) | |
coutis located inside the std namespace, btw.same as many other methods and variables. std::string and std::vector<T> for example. Both are located in string.h and vector.h libraries.
| |
|
|
|
| TheIdeasMan (1753) | |||
|
@kaidto It is normal practice to not do what you are saying. It is OK for beginners - but sooner or later they need to break this bad habit. This is because using std namespace; brings in the whole std namespace - polluting the global namespace, which can cause naming conflicts. Go with JLBorges's advice.The other thing to do is have:
for frequently used things, use std:: for other things.Also - main returns an int, not void. | |||
|
|
|||
| vlad from moscow (3662) | ||
Use it as your own namespace.:) | ||
|
|
||
| kaidto (12) | ||
It was my fault, but I realize that now. It happens to be more decent to declare each using statement.
| ||
|
|
||