• 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: Bilingual shenanigans
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bilingual shenanigans


  • Subject: Re: Bilingual shenanigans
  • From: Ondra Cada <email@hidden>
  • Date: Fri, 13 Sep 2002 21:54:39 +0200

On Friday, September 13, 2002, at 08:19 , Dean Tresner wrote:

Pretty.h:
@class Plain;
@interface Pretty : NSObject {
Plain *x;
...

No problem with this.

Plain.h:
class Ugly;
@interface Plain : NSObject {
Ugly y;
...

Can't. Either use "Ugly *y", or #import the header.

Ugly.h:
class Uglier;
class Ugly {
Uglier z;
...

Ditto.

the compiler will tell me "y has incomplete type." If I put the #include directives in the .h files to avoid the forward declarations, things get even more confusing for both me and the compiler. What's the right way to do this?

So far as you use *pointers to classes*, @class or class directive is sufficient. The problem is caused by the C++ evil feature of value instances.

If there is "one-way" of declarations, you can follow it: #include Uglier.
h into Ugly.h; #import Ugly.h into Pretty.h. Be careful not to close loop (ie., not to eg. #include Pretty.h into Uglier.h).

If there is a loop, then oops. So far as I know, there is just *no way* to have

class A {
B b;
};

class B {
A a;
};

in C++ (though, I am no C++ expert -- someone may know a solution). So far as I know though, you just have to use at least in one case a pointer.
---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Bilingual shenanigans (From: Dean Tresner <email@hidden>)

  • Prev by Date: Re: Scope of [NSMutableDictionary setObject:] in an array
  • Next by Date: Re: contextual menu and NSTextField
  • Previous by thread: Re: Bilingual shenanigans
  • Next by thread: Bilingual shenanigans
  • Index(es):
    • Date
    • Thread