Problem

This exercise is intended to illustrate namespaces and separate compilation in your develo...

This exercise is intended to illustrate namespaces and separate compilation in your development environment. You should use the development environment you regularly use in this course for this exercise. In a file f.h, place a declaration of void f() in namespace A. In a file g.h, place a declaration of void g() in namespace A. In files f.cpp and g.cpp, place the definitions of void f() and void g(), respectively. Place the definitions of void f() and void g() in namespace A. The functions can do anything you want, but to keep track of execution include something like

where Function_Name is the name of the particular function. In another file, main.cpp, put your main function, #include the minimum collection of files to provide access to the names from namespace A. In your main function call the functions f then g. Compile, link, and execute using your development environment. To provide access to names in namespaces, you may use local using declarations such as

or use local using directives such as

inside a block, or qualify names using the names of namespaces, such as std::cout.

You may not use global namespace directives such as the following which are not in a block and apply to the entire file:

Of course you must handle namespace A and function names f and g, in addition to possibly std and cout.

After doing this, write a one page description of how to create and use namespaces and separate compilation in your environment.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 11