Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!maytag!watstat.waterloo.edu!dmurdoch From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Newsgroups: comp.lang.pascal Subject: Re: TP6.0 OOP Quiery Message-ID: <1991Jun17.005251.1184@maytag.waterloo.edu> Date: 17 Jun 91 00:52:51 GMT References: <1991Jun16.075044.18283@cs.mcgill.ca> Sender: news@maytag.waterloo.edu (News Owner) Organization: University of Waterloo Lines: 27 In article <1991Jun16.075044.18283@cs.mcgill.ca> storm@cs.mcgill.ca (Marc WANDSCHNEIDER) writes: > >In the TP 6.0 Users manual, they start building up OOPs with objects typed >Location and Point. ... > >MY problem is: Why have they declared an INIT procedure for type Point, when >Location already has this procedure declared. If objects have inheritance, >then there should already be an INIT procedure built into the Point type. In the example you gave, you are correct: though declared as constructors, the two Init routines are just procedures. However, in more complicated cases, it's essential that an object have its own constructor, because it's the constructor that "stamps" the object with its dynamic type. If you had virtual methods in your Point, but called the Location constructor to initialize it, you'd get the Location virtual methods, not the Point ones. This causes problems sometimes. If in your Point constructor, you make a call to an ancestor's constructor without giving the type (impossible here, because they both have the same name) it'll "transmute" your object into the ancestor type, and you'll end up very confused later. I hope this helps a bit. Duncan Murdoch dmurdoch@watstat.waterloo.edu