In article <1203048264_1026@[EMAIL PROTECTED]
>, invalid@[EMAIL PROTECTED]
says...
[ ... ]
> #include <iostream.h>
> #include <vectors.h>
That would be:
#include <iostream>
#include <vector>
If your book includes '.h' on the names of the standard headers, it's
very out of date.
> I don't need anything off the command line, so I think that
> int main (void) { return 0; }
> is right. ??
That's reasonable, yes.
> I'm given to understand that many of fortran's vector capabilities have
an
> analog in c++. How would I declare and print a single four_vector, with
> double-wide real entries. For the purpose of illustration, let's make
the
> ith entry the real square root of i:
That's fairly trivial. This doesn't really do anything to ensure that
four_vector really remains a vector of four objects -- if you changed
the limit in the loop to '100.0' (or whatever) it would happily build
that size of vector. Of course, if you decide "whatever" includes
something like 1E200, chances are you'll have a hard time finding a
computer with enough memory (even drive space) to hold the results. Then
again, you'll probably find the memory about as quickly as you find
patience to wait for the results...
#include <vector>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <math.h>
int main() {
std::vector<double> four_vector;
for (double i=0.0; i<4.0; i++)
four_vector.push_back(sqrt(i));
std::copy(four_vector.begin(), four_vector.end(),
std::ostream_iterator<double>(std::cout, "\n"));
return 0;
}
--
Later,
Jerry.
The universe is a figment of its own imagination.


|