In this lesson, our instructor Alvin Sylvain goes through an introduction on namespaces. He discusses namespace for class association, how units can share namespace, using namespaces for types and classes, using explicit namespace, 'using' keyword, using for particular names, naming strategy, namespace aliases, and avoiding duplicates.
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Intermediate C++
Mr. Sylvain, so I am selectively picking the videos I have to watch to understand object oriented programming first. I would be glad if you could tell me as to which lecture talks about static functions, static variables, const functions, inline functions etc.
Namespaces
Copy a new version of your “Auto” homework. Remove every line that reads: using namespace std;
That will mean adding “std::” to every element in the standard namespace.
Create a new namespace for each object class you defined. Call it: homework_cplusplus_educator_com
In any block or CPP file where you may have numerous uses of “cout”, “endl”, etc., add: using std::cout;
or, “std::endl”, or which ever name you’d like to use without the “std::” qualifier.
If you put the “main” function inside the same namespace as the other classes, remove it from that namespace. (It should be in a separate file anyway.) Now you’ll need to reference your classes with their namespace, e.g., “homework_cplusplus_educator_com::Auto”.
Add a namespace alias, such as “homework”, so you won’t need to type the entire namespace name for “homework_cplusplus_educator_com.” (This is not just to save on your typing; the code will also be easier to read.)
Make sure everything still compiles and runs!
Namespaces
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.
Go Daddy is the world’s #1 domain name registrar. In addition to domain registration and hosting, Go Daddy also provides e-business related software and services.
Bluehost was recently awarded Best New Hosting Company and Best Customer Support by the some of the leading hosting review companies. $6.95/month hosting.
Bigcommerce is an easy to use eCommerce software with over 30,000 online stores. If you are interested in building your own eCommerce website, Educator.com highly recommend giving Bigcommerce a try!
0 answers
Post by Ram Manohar Oruganti on November 13, 2014
Mr. Sylvain, so I am selectively picking the videos I have to watch to understand object oriented programming first. I would be glad if you could tell me as to which lecture talks about static functions, static variables, const functions, inline functions etc.