Well, #include <stdio.h> haven't any effect,it can delete,and this Statement 
if(alist == NULL) not have anyquestion.
Because in head file already define NULL

 But you does not make clear  how to modified.

________________________________
From: peternilsson42 <[email protected]>
To: [email protected]
Sent: Thursday, June 11, 2009 8:03:08 AM
Subject: [c-prog] Re: template class of array.





--- In c-p...@yahoogroups. com, "iamwljiang" <iamwljiang@ ...> wrote:
>
> This code have link error,but I can't find it.
> I need someone help me find it and tell me where is error
> and why...
> 
> I use Dev-C++ compile it that the error show is Array(int n=50);
> and ~Array() link error. 
> 
> //////////// ///////// ///////// ///////// //
> ///Array.h 
> ///
> //////////// ///////// ///////// /////////
> #ifndef _ARRAY_H_

Identifiers with leading underscores are reserved. Use
something like H_ARRAY_H. Don't use names like ARRAY_H
because all-cap identifiers starting with E. [cf <errno.h>]

<snip>
> //////////// ///////// ///////// ///
> //
> //array.cpp
> //////////// ///////// ///////// //

Compiling a file of template definitions won't instantiate
those definitions. Hence, most C++ headers include class
and function definitions so they get instantiated when
used. The linker will then strip out duplicates.

You should look up explicit template instantiation in your
C++ book.

> #include "array.h"
> #include <stdio.h>

Why use stdio.h?!!!

<snip> 
>     if(alist == NULL) Error(memoryAllocat ionError) ;

Don't use NULL, use 0.

<snip>
> if(n < 0) Error(invalidArrayS ize);
> 
> T>::~Array()
> { alist = new T[size];

Well this is screwed up! I'm surprised it compiled.

-- 
Peter


   


      

[Non-text portions of this message have been removed]

Reply via email to