| www.delorie.com/archives/browse.cgi | search |
| From: | jesjones AT halcyon DOT com (Jesse Jones) |
| Newsgroups: | comp.lang.c++,comp.os.msdos.djgpp,rec.games.programmer |
| Subject: | Re: Template Class as Object Function Parameter |
| Date: | Thu, 22 Jan 1998 22:00:00 -0700 |
| Organization: | Edmark |
| Lines: | 23 |
| Message-ID: | <jesjones-ya02408000R2201982200000001@news.accessone.com> |
| References: | <34C8192D DOT 6DE290C4 AT nwrain DOT com> |
| NNTP-Posting-Host: | 12264 AT 204 DOT 201 DOT 213 DOT 51 |
| Mime-Version: | 1.0 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
In article <34C8192D DOT 6DE290C4 AT nwrain DOT com>, obremski AT nwrain DOT com wrote:
> I was just wondering why the following code doesn't work. I have a
> template class called Array. 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<dt> *src' would work, but i
> get errors. Please help =)
>
> template <class dt>
> int Array<dt>::copy (Array<dt> *src, long int loc)
> {
>
> // --- function meat goes here =) --- \\
>
> return 0;
> }
Looks like it should work to me. What kind of errors are you getting? BTW
when copying objects within template code it's a good idea to use STL's
copy function. Quality implementations will provide specializations of
copy() for simple types like ints and floats that can be copied via memcpy.
--Jesse
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |