Re: just C++ in xcode
Re: just C++ in xcode
- Subject: Re: just C++ in xcode
- From: Andreas Grosam <email@hidden>
- Date: Tue, 4 Oct 2005 12:31:06 +0200
On 04.10.2005, at 03:18, Joe Kurtz wrote:
Thanks Andreas,
I think for me this is the crux:
Even though linkages in namespaces "extern" by
default, the keyword "extern" is still required in
order to separate the declaration of a variable from
its definition and (default) initialization.
Yes, for *objects*. Using "export" this is the only way to declare a variable without defining it. They need a definition elsewhere.
Not obvious.
For ordinary types like int, short etc., maybe this is true - but now consider a class MyClass:
int x; // definition? yes. initialization? yes
MyClass
foo; // definition!, calls default c-tor to initialize the variable foo.
Although the latter still might be questionable and lacks argumentation, this should be *more* obvious, isn't it?
Is there any other way to separate
declaration and definition?
Functions and classes for instance, do not need "extern" to declare them without defining them:
Declaration:
namespace N { void foo(); }
namespace N { class Foo; }
Definition:
namespace N { void foo() { ... } }
namespace N { class Foo { ... }; }
Finally, a hint:
DonĀ“t use global variables! Encapsulate them in classes, initialize them in the class' c-tor and use (member) functions to access them.
Regards
Andreas
Cheers,
Joe
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden