• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Objective-C++, class scope constants, name conflicts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C++, class scope constants, name conflicts


  • Subject: Re: Objective-C++, class scope constants, name conflicts
  • From: Ricky Sharp <email@hidden>
  • Date: Thu, 9 Feb 2006 18:03:59 -0600


On Feb 9, 2006, at 5:23 PM, 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
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...

Perhaps something on this page may help:

<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ Articles/chapter_4_section_10.html>

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
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


References: 
 >Objective-C++, class scope constants, name conflicts (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: Objective-C++, class scope constants, name conflicts
  • Next by Date: Re: WebView question
  • Previous by thread: Objective-C++, class scope constants, name conflicts
  • Next by thread: Re: Objective-C++, class scope constants, name conflicts
  • Index(es):
    • Date
    • Thread