From: Robert White Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,rec.games.programmer Subject: Re: Template Class as Object Function Parameter Date: Tue, 27 Jan 1998 02:47:01 -0500 Organization: Bell Atlantic Internet Solutions Lines: 50 Message-ID: <34CD90F4.9736DD18@pobox.com> References: <34C8192D DOT 6DE290C4 AT nwrain DOT com> NNTP-Posting-Host: client-151-200-122-209.bellatlantic.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk The following is an primary example of an unanswerable question. You need to tell us what errors you are getting and sow us the code that is *calling* the template. The errors you are getting are almost certianly an invocation time issue and not an definition time issue. The tiny (deleted for brevity) code fragment you provided in your original article is syntatically correct so the problem is doubtless elsewhere. Neil & Joey Obremski wrote: > And in one function I wish to have a > parameter that is of this class and the SAME type as the current class > object. So I naturally thought that 'Array
*src' would work, but i > get errors. BTW: template class Array { ... typedef Array MyType; // Handy type renaming to reduce confusion int copy(MyType &, long); //Almost always copy "references" ... }; template int Array::copy(MyType & Oroginal, long StartPos) { } And furthermore: You "probably" would be better off writing this as a copy constructor and then an assignment operator then "adding in" the Start Position to the two afore mentioned functions. I note this because your choice of return type (taken from original post) indicates that you are not so much "making a new copy of" the supplied input, as much as you are "replacing the contents of the current array with a copy of" the supplied input. The "starting at a spesific offset" is far less significant a factor than the "replace". LASTLY: Do be sure to check to be sure that (&Original != this) before you start to monkey around because if (&Original == this) then you have a "trim" not an copy to do... Rob. Remove Anti-Spam from my return address to reply via email.