Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
the compiler doesnt find immediately function call

The compiler doesnt find immediately function called initialize

Selected C++ Topics 937

void RunGame(void) {
// initialize 3D engine
MyCool3DEngine::Initialize(); // etc.


ords class, struct, a in addition to creat e.The namespace ke ates a namespace,

espaces ums,
already spaces.

using namespace MyCool3DEngine;

void RunGame(void) {

This works similar to how a search path works for files. The using namespace line tells the compiler that if it can’t find a function, it should look for it within the specified namespace. In the previous example, if the compiler doesn’t find immediately a function called Initialize, it looks in the namespace MyCool3DEngine.

The using namespace feature is handy, not only because it saves you some keystrokes, but also because if the name of the namespace changes, you only have to adjust the code in one place (that is, you only have to change the using namespace line).

938 B.


The using your curr

u put a ody, it’s tion.

al scope.

You can also nest namespaces. Think of the scope resolution operator, ::, as the equivalent to the backslash in the file system (it’s not quite as versatile, but it’s a good analogy for right now). For example, let’s say you have name-space A embedded in namespace B, like so:

namespace A {

You could get to Foo by writing:


y, you not only solve hing problem, but y better job of isolati other people’s cod later changes the n e, all you need to c lias line, and you’re he
u can
If the
e of its nge is
od to


The C++ S entirely w
quently in

ndard Template Library i in a namespace called st urce files that use STL, y ace std lines, or you’ll se functions and data types ontained So, fre-
’ll see
td:: pre-

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File

Uploaded by : Joseph Robertson

PageId: ELI9E38C06