Question: write a program using a single file containing three namespaces X , Y and Z so that the following main() works correctly: int main() {

write a program using a single file containing three namespaces X, Y and Z so that the following main() works correctly:

int main() { X::var = 7; X::print(); // print X's var using namespace Y; var = 9 ; print(); // print Y's var { using Z::var; using Z::print; var = 11; print(); // print Z's var } print(); // print Y's var X::print(); // print X's var } 

Each namespace needs to define a variable called var and a function called print() that outputs the appropriate var using cout.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!