Re: Read a textfile to an array



"JP" <JP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>Hi; I need some help with writing a member function really badly. I have a
>template class with the constructor as follows:
>
>//constructor
>
>template <class T>
>MyClass<T>::MyClass(int s)
>{
> size = s;
> T array = new T[size];
>}
>
>//member function prototype
>
>template <class T>
>void MyClass<T>::ReadFile(char *file){};
>
>sombody please help me define the member function so that it will accept a
>filename and then it reads the file and then add the values to the array that
>was created by the constructor.

Is this a homework assignment?

Are the contents of the file supposed to be stored into the array you
already have, or do you need to add additional space? Reading into the
existing array is trivial. What do you already have?
--
- Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc
.



Relevant Pages

  • Re: Question About temlates.
    ... >will act like a dynamic array. ... You're describing the right approach to creating a template from a ... a dynamic array generally means that there's at least one ... many elements in the constructor. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Question About temlates.
    ... Leor Zolman wrote: ... but what I want to do is create a template class that ... >>will act like a dynamic array. ... > many elements in the constructor. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Read a textfile to an array
    ... I need some help with writing a member function really badly. ... > template class with the constructor as follows: ... as a variable that's local to the ctor, so as soon as the ctor ... > was created by the constructor. ...
    (microsoft.public.vc.language)
  • Read a textfile to an array
    ... I need some help with writing a member function really badly. ... template class with the constructor as follows: ...
    (microsoft.public.vc.language)
  • Re: Non-inline template specialization of member function okay?
    ... template T Createconst; ... implemented in its CPP file: ... Member function specialization cannot be declared inside the class. ... INTERNAL COMPILER ERROR (compiler file ...
    (microsoft.public.vc.language)