I'm taking an intro to c++ class and during an exercise I ran into multiple errors that are out of my knowledge to fix. The rest of the class is using Visual and that is all the instructor knows so i'm in my own figuring out Xcode. Basically I wrote the same program twice but one has a different struct and I get all sorts of errors with it. I was hoping someone could help me understand what the errors are and why they occurred.

The working program is this:

#include <iostream>

#include <fstream>

#include <iomanip>

#include <cmath>

using namespace std;

struct point

{

public:

double x1,y1;

double x2,y2;

};

double distance(point);

int main (int argc, const char * argv[])

{

point point;

double dist;

ifstream infile("/Value.txt");

ofstream ofile("/Output.txt");

ofile<<" X1 Y1 X2 Y2 Distance\n";

ofile<<" --- --- --- --- --------\n";

ofile<<fixed;

ofile<<showpoint;

ofile<<setprecision(2);

do

{

infile>>point.x1>>point.y1>>point.x2>>point.y2;

dist = distance(point);

ofile<<setprecision(1);

ofile<<setw(4)<<point.x1;

ofile<<setw(7)<<point.y1;

ofile<<setw(7)<<point.x2;

ofile<<setw(7)<<point.y2;

ofile<<setprecision(2);

ofile<<setw(11)<<dist<<endl;

} while (!infile.eof());

infile.close();

ofile.close();

return 0;

}

double distance(point point)

{

double d;

d=sqrt(pow(point.x2-point.x2, 2)+pow(point.y2-point.y1, 2));

return d;

}

Now when I change the struct to how the teacher wants it the program looks like:

#include <iostream>

#include <fstream>

#include <iomanip>

#include <cmath>

using namespace std;

struct point

{

public:

double x,y;

};

double distance(point, point);

int main (int argc, const char * argv[])

{

point one, two;

double dist;

ifstream infile("/Value.txt");

ofstream ofile("/Output.txt");

ofile<<" X1 Y1 X2 Y2 Distance\n";

ofile<<" --- --- --- --- --------\n";

ofile<<fixed;

ofile<<showpoint;

ofile<<setprecision(2);

do

{

infile>>one.x>>one.y>>two.x>>two.y;

dist = distance(one, two);

ofile<<setprecision(1);

ofile<<setw(4)<<one.x;

ofile<<setw(7)<<one.y;

ofile<<setw(7)<<two.x;

ofile<<setw(7)<<two.y;

ofile<<setprecision(2);

ofile<<setw(11)<<dist<<endl;

} while (!infile.eof());

infile.close();

ofile.close();

return 0;

}

double distance(point one, point two)

{

double d;

d=sqrt(pow(two.x-one.x, 2)+pow(two.y-one.y, 2));

return d;

}

This program does not compile and I get the following errors:

stl_iterator_base_types.h

1) Symantic Issue

No type named 'value_type' in 'myPoint'

2) Symantic Issue

No type named 'iterator_category in 'myPoint'

3) Symantic Issue

No type named 'difference_type' in 'myPoint'

4) Symantic Issue

No type named 'pointer' in 'myPoint'

5) Symantic Issue

No type named 'reference' in 'myPoint'

Why does one work and the other doesn't!? This is more than frustrating.