C++ Namespace Concepts: Using Namespaces abc and xyz, Exercises of Object Oriented Programming

A c++ code example demonstrating the use of namespaces abc and xyz. The code includes a header file (namespace.h) and a source file (namespace.cpp). The main function initializes a variable 'a' in each namespace and uses the 'using namespace' statement to select the desired namespace for output. The output will be either an integer or a float value based on the selected namespace.

Typology: Exercises

2011/2012

Uploaded on 07/31/2012

netu
netu 🇮🇳

4.5

(4)

50 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
C:\Documents and Settings\Administrator\My ...Studio 2010\Projects\namespace\namespace\namespace.h
# include < stdio . h >
namespace abc
{
int a ;
}
namespace xyz
{
float a ;
}
docsity.com
pf2

Partial preview of the text

Download C++ Namespace Concepts: Using Namespaces abc and xyz and more Exercises Object Oriented Programming in PDF only on Docsity!

C:\Documents and Settings\Administrator\My ...Studio 2010\Projects\namespace\namespace\namespace.h 1

include <^ stdio^.^ h^ >

namespace abc { int a; }

namespace xyz { float a; }

docsity.com

C:\Documents and Settings\Administrator\My ... 2010\Projects\namespace\namespace\namespace.cpp 1

#include #include "namespace.h"

//using namespace abc; //this will print integer in the output using namespace xyz; //this will print float in the output

void main() { a = 2. 221 ; //printf("%d", a); printf("%f", a); getch();

}

docsity.com