Objective-C++, class scope constants, name conflicts
Objective-C++, class scope constants, name conflicts
- Subject: Objective-C++, class scope constants, name conflicts
- From: Scott Ribe <email@hidden>
- Date: Thu, 09 Feb 2006 16:23:39 -0700
- Thread-topic: Objective-C++, class scope constants, name conflicts
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
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:
This email sent to email@hidden