I am using a book assigned for a class which seems to mix C style and C++ style code and calls it C++ , for ex. the following
Code:
#include <math.h>
#include <iostream.h>
#include <stdlib.h>
struct point { float x; float y; };
float randFloat()
{ return 1.0*rand()/RAND_MAX; }
int main(int argc, char *argv[])
{ float d = atof(argv[2]);
int i, cnt = 0, N = atoi(argv[1]);
point *a = new point[N];
for (i = 0; i < N; i++)
{ a[i].x = randFloat(); a[i].y = randFloat(); }
for (i = 0; i < N; i++)
for (int j = i+1; j < N; j++)
if (distance(a[i], a[j]) < d) cnt++;
cout << cnt << " pairs within " << d << endl;
}
does this "iostream.h" come with any compiler standard? I get file not found, only the regular <iostream> exists on my computer, using gcc ( i think )
If I change it to <iostream> , as I *think* it should be, then of course I get the missing namespace error for cout ... ok then if I add the using namespace std statement that he might (?) have left out ... then I get a conflict with the distance function already being defined in std...
My question is, is it possible that this code actually compiled on SOME major compiler that I don't know of?