Thanks for the response, Kevin. It was amazingly apt, for me, because it's
*exactly* the point I was reading about last night :-) In fact, your next
post, about TObjList is apt, too, because (continuing the same example),
students don't register for single courses & courses aren't assigned single
students. Here's what I'm wondering at this point ...
So Student has a field Course of type TCourse, and the Register procedure
associates a TCourse object with Student--I got that. I also understand the
need to create an empty TCourse object in the TStudent constructor. I'm
assuming that Student.Register (CourseName:String) would need to
(a) find a TCourse object whose CourseName field matches the one from the
signature with Student,
*have Student's Course field point to this TCourse instead of the blank one
created in the constructor,* AND
(b) the same TCourse object would need to associate Student with itself (add
Student to a TObjList?)...
Right?
This stuff is making my head spin! I'd love to return to writeln('hello
world') :-)
Thanks again for your responses, though. You and others on this list have
been really helpful.
Al
> One technique I often use in a custom class is to put a 'pointer' or
> instance variable to another custom class:
>
> eg.
> tCourse = class(tcomponent)
> public
> CourseName: string;
> //course specific variables/methods etc.
> end;
>
> tStudent = class(tcomponent)
> public
> Course : tcourse;
> procedure Register(CourseName: string);
> //student specific variables/methods etc.
> end;
>
> var Student: tStudent;
>
> The Register method in tStudent could be used to assign the value of
> CourseName
> which may then be referenced as Student.Course.CourseName
>
> An instance, Student, of tStudent has to create an instance of Course in
> its
> constructor
> (so that Course has assigned memory and is not NULL),
> but then all the methods of tCourse are already available within the
> tStudent
> object;
>
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi