Re: Using a Resource as a Class Property
- From: Sanders Kaufman <bucky@xxxxxxxxxxx>
- Date: Sun, 22 Jul 2007 01:33:59 GMT
Michael Fesser wrote:
.oO(Sanders Kaufman)
So I'm doing it right?! Cool.
It always depends on what you want to achieve. From just looking at the
posted snippet and without knowing what the my_baseclass is supposed to
do, it's hard to tell whether you're doing it right or not, since the
code is not doing anything useful, except for initializing some member
variables.
I know there are some cases where you're supposed to serialize objects instead of... what am I doing, passing by reference? Instantiating?
Aggregating. ;) You create an instance of a class, which is used inside
another object. That's it (in this case).
Serializing can be used if you want to store an object to a file or a
database.
Micha
OK - that was weird, and took some debugging.
I knew there was *something* about scope to deal with here.
I'm aggragating the database object into a base class, and then creating other classes that "extend" that base class.
HOWEVER, in order to do that, I had to move the instantiation(?) of the database class into the extended class. When I had it in the base class, the class that extended it could not see the database properties and functions.
Whew.
.
- Follow-Ups:
- Re: Using a Resource as a Class Property
- From: Michael Fesser
- Re: Using a Resource as a Class Property
- References:
- Using a Resource as a Class Property
- From: Sanders Kaufman
- Re: Using a Resource as a Class Property
- From: Michael Fesser
- Re: Using a Resource as a Class Property
- From: Sanders Kaufman
- Re: Using a Resource as a Class Property
- From: Michael Fesser
- Using a Resource as a Class Property
- Prev by Date: Re: Framework, which one?
- Next by Date: Re: Using a Resource as a Class Property
- Previous by thread: Re: Using a Resource as a Class Property
- Next by thread: Re: Using a Resource as a Class Property
- Index(es):
Relevant Pages
|