Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 2

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,

ve
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.

TIP

The using your curr

within
u put a ody, it’s tion.

espace
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:

A::B::Foo();

TIP
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
your
If the
e of its nge is
od to

TIP

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-
How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELI9E38C06
img
Uploaded by :
Yy3v3YVm
Page 1 Preview
the compiler doesnt find immediately function call
Sell Your Old Documents & Earn Wallet Balance