Re: Objective-C++, class scope constants, name conflicts
Re: Objective-C++, class scope constants, name conflicts
- Subject: Re: Objective-C++, class scope constants, name conflicts
- From: Tommy Nordgren <email@hidden>
- Date: Sat, 11 Feb 2006 20:28:59 +0100
On Feb 10, 2006, at 12:23 AM, Scott Ribe wrote:
What I need is essentially a constant integer value with class
scope. In C++
I got used to the class enum trick, but I don't know what to do in an
Objective-C class.
I tried "static const int controlSetCnt = 0;" inside the
@interface, but
this causes the compiler to crash. So I moved it outside the
@interface, and
Either declare it as static const int inside the IMPLEMENTATION file,
or, since you're using it in objective c++, define it inside a
NAMESPACE in the header
file.
it appeared to work fine. However, as soon as I have another class
with the
same need and use the same technique, I get "error: redefinition of
'const
int controlSetCnt'". This is because there is one implementation
file (my
application delegate) that has to know enough about both these
classes to
instantiate them. The constant needs to be in the header file,
because it
defines the size of an array member of the class:
BloodPressure_ControlGroup * bpControls[controlSetCnt];
So my question is: do I really have to avoid this kind of name
conflict by
naming a simple constant, which is only used in one class, and not
exported
to the linker, with an awful name like:
controlSetCountForClinicExamWindowController
Well, amusingly enough, there is actually an appropriate C++
namespace for
each, so my other option is foo::bar::controlSetCnt...
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40chello.se
This email sent to email@hidden
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden