On Sep 16, 9:53 pm, philbo30 <masfe...@gmail.com> wrote:
> On Sep 16, 3:08 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
[...]
> What would be the alternative to vector? When I try to use the above,
> later in the code, I get the following error during compilation with g++:
> no matching function for call to 'DoubleArray:
oubleArray
> (vector<double, allocator<double> > &, unsigned int)'
> candidates are: DoubleArray:
oubleArray ()
> DoubleArray:
oubleArray(const double *,int)
> DoubleArray:
oubleArray(conts DoubleArray &)
If you use std::vector, you have to use std::vector. The
idiomatic solution would be to give DoubleArray a template
constructor:
template< typename Iterator >
DoubleArray:

oubleArray(
Iterator begin,
Iterator end )
But before going any further, obviously, we would have to know
more about DoubleArray. If you give it the above constructor,
then you may not need the vector to begin with; you can
initialize it directly from the std::istream_iterator. Provided
it is written to work with input iterators, and not just random
access iterators.
If you need to access legacy code, which you cannot change, and
which expects a double*, int, you can use &vect[0] and
vect.size().
> I just started to work with C++ today, but I have decent
> experience with C.
Forget your C experience to begin with. It will come into good
use later, when you've mastered the basic idioms of C++, but
typically (and especially where collections of data are
concerned), good, idiomatic C++ is very, very different from C.
(You might want to get "Accelerated C++", and try working
through it quickly, pretending you don't know C.)
--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34