objectifying a struct
objectifying a struct
- Subject: objectifying a struct
- From: Keith Ray <email@hidden>
- Date: Sat, 4 Feb 2006 16:37:46 -0800
In C/C++ legacy code, I can incrementally refactor C code using
structs in C++ code using classes. First by declaring constructors and
moving initialization code into the constructors. Then, replacing
usage of "malloc" and "free" with "new" and "delete". Then declaring a
destructor (if necessary); moving other code into methods, and
eventually declaring the member variables private and creating public
accessors/mutators for them (if needed). Since the only difference
between the declaration of "struct" and "class" in C++ the default
accessibility of the members, it doesn't really matter when I change
that keyword in the declaration.
If I wanted to do something similar, but end up with an Objective-C
subclass of NSObject, what steps would you recommend?
It seems like changing the "struct" declaration to an "interface"
declaration immediately breaks a lot of code because the member
variables immediately become private, but it has to be done earlier
than in C++, in order to declare "init" and other methods.
--
C. Keith Ray
<http://homepage.mac.com/keithray/blog/index.html>
<http://homepage.mac.com/keithray/xpminifaq.html>
<http://homepage.mac.com/keithray/resume2.html>
_______________________________________________
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