Re: Obj-C++ Tuturial Anywhere?
Re: Obj-C++ Tuturial Anywhere?
- Subject: Re: Obj-C++ Tuturial Anywhere?
- From: Andreas Monitzer <email@hidden>
- Date: Thu, 16 Aug 2001 00:25:16 +0200
On Thursday, August 16, 2001, at 12:03 , Todd Blanchard wrote:
Sure - here is my guidelines.
1) Minimize the use of C++ constructs as much as possible - zero is ideal.
2) Don't export C++ interfaces in your frameworks - only export Objective
C
wrappers.
3) When considering the use of templates, see 1.
4) Ditto operator overloading.
5) The only other good use might be the following "smart releasing
pointer"
class:
class Id
{
id _object;
Id(id obj) : _object([obj retain]) {}
~Id() { [_object release]; }
operator id() { return _object; }
}
...
{
Id foo = [MyClass newObject];
} // destructor releases foo
This might not work though - I haven't tried it as I don't have the new
thingy.
Correct C++ is:
Id foo([MyClass newObject]);
as far as I can remember (been a while :). However, using autorelease is
much easier and does the same.
And my guideline is:
6) Don't create new C++-classes. Use ObjC++ only for porting legacy code
or declaring variables in the middle of a block (hehe :-).
andy
--
Description forthcoming.