From: Renato De Leone Newsgroups: comp.os.msdos.djgpp Subject: HELP with templates Date: Wed, 12 May 1999 15:15:17 +0200 Organization: =?iso-8859-1?Q?Universit=E0?= di Camerino Lines: 89 Message-ID: <37397EE0.ADFF172@camserv.unicam.it> NNTP-Posting-Host: cicnew.unicam.it Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8BCFCA9D1F49ED95366A014B" X-Trace: news.cineca.it 926519142 6970 193.204.8.11 (12 May 1999 14:25:42 GMT) X-Complaints-To: news AT cineca DOT it NNTP-Posting-Date: 12 May 1999 14:25:42 GMT X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en,it,ja,de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com This is a multi-part message in MIME format. --------------8BCFCA9D1F49ED95366A014B Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Maybe this is a FAQ but I was unable to find the answer. What is wrong? What do I need to add to correctly compile and run the program? -- Renato De Leone Università di Camerino Dipartimento di Matematica e Fisica Camerino (MC) ITALY PHONE: +39-737-402532 deleone AT camserv DOT unicam DOT it FAX: +39-737-632525 http://www2.unicam.it/~deleone --------------8BCFCA9D1F49ED95366A014B Content-Type: text/plain; charset=us-ascii; name="all" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="all" -----------array.h------------------ template class Array{ private: T data_[10]; public: T & set(int k); T value(int k){return data_[k];} }; -----------array.cc------------------ #include "array.h" template X & Array::set(int k) { return data_[k]; } -----------main.cc------------------ #include #include "array.h" main() { Array a; Array b; a.set(0) = 1; b.set(0) = 5.2; cout << a.value(0) << "\n"; cout << b.value(0) << "\n"; } ----------Makefile------------------ .SUFFIXES: .SUFFIXES .cc SRC = main.cc array.cc OBJ = main.o array.o lista.exe: array.h $(OBJ) g++ -o array.exe $(OBJ) -lgpp .cc.o: g++ -xc++ -c $*.cc -o $*.o array.o: array.h main.o: array.h --------------8BCFCA9D1F49ED95366A014B--