-
June 11th, 2018, 03:31 PM
#31
Re: using namespace std
Thank you all for great explanations and suggestions.
-
June 12th, 2018, 01:56 AM
#32
Re: using namespace std
One aspect of namespaces is that it's a good idea to introduce your own namespaces in your programs. You sub-divide your program into namespaces where each namespace contains code that naturally belong together. Best is to not use using at all but instead qualify each symbol/name with its namespace. In this way you avoid name clashes and it's immediately obvious where a certain symbol/name originates in your own code as well as in code by others such as the standard library.
Also note that the splitting of C++ programs into .h and .cpp files is a convention and not stipulated by the C++ language. Unfortunately this practice is still upheld in most schools so after a C++ newbie course students usually come away with the impression that .h/.cpp splitting is essential to C++ when today the trend is rather the opposite. One example is the increasing number of third-party libraries consisting of .h files only.
Bjarne Stroustrup has said that C++ 11 feels like new language with a more high-level style of programming (rather than struggling with copy constructors and assignment operators to manage low-level memory for example). It will be interesting to see whether/how this is reflected in the second edition of his book "A Tour of C++" due on June 29.
Last edited by wolle; June 13th, 2018 at 02:26 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|