• 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: how to pass arguments by reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to pass arguments by reference


  • Subject: Re: how to pass arguments by reference
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 10 Dec 2008 09:54:03 -0600

On Dec 10, 2008, at 9:45 AM, Dave DeLong wrote:

Put the & before the variable type:

- (UInt32) traverseTreeStraightReturnedDirection: (&int)treeDirection...

I haven't tried that, but it doesn't look right. It doesn't correspond to any C or C++ syntax I've ever seen.



On Dec 10, 2008, at 8:43 AM, Nick Rogers wrote:

Hi,
I have the following in my .m file:


- (UInt32)traverseTreeStraightReturnedDirection:(int&)treeDirection returnedTreeDepth:(int&)treeDepth returnedKey:(HPlusCatalogKey&)catKey lookForKey:(HPlusCatalogKey)lastKey { // code here }

But the error when compiling is "parse error before & token".
Is passing by reference not allowed or is there any other syntax that I should follow?

References are a language feature of C++. Neither C nor Objective-C has such a notion. You would have to use Objective-C++, which is usually accomplished by using a .mm extension for your source file.


Note that if you use C++ features in a header file, then all translation units which include that header will have to be C++ or Objective-C++, unless you conditionalize the code with "#ifdef __cplusplus".

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >how to pass arguments by reference (From: Nick Rogers <email@hidden>)
 >Re: how to pass arguments by reference (From: Dave DeLong <email@hidden>)

  • Prev by Date: Re: how to pass arguments by reference
  • Next by Date: Re: how to pass arguments by reference
  • Previous by thread: Re: how to pass arguments by reference
  • Next by thread: Re: how to pass arguments by reference
  • Index(es):
    • Date
    • Thread