I'm taking an intro to OOP with c++ class and we were introduced to structures. The teacher wants us to create a structure Point that will be the x and y coordinate of a point and then use those to do various things. An example of what she wants would be " dist – this function will receive two Points and calculate and return the distance between the Points." However, I'm getting an error any time I try to pass to points into a function.
For example if I initialize
float dist(Point a);
define
float dist(Point a){
return 1;
}
I don't get an error, but if I say
float dist(Point a, Point b);
float dist(Point a, Point b){
return 1;
}
The error pops me to a different screen and highlights the line
typedef typename _Iterator::iterator_category iterator_category;
Am I not able to pass two structures in that way or am I just misreading her instructions?
Thanks in advance.
Edit: Here is the complete code as requested that doesn't work.
#include <iostream>
#include <cmath>
using namespace std;
struct Point{
float x;
float y;
}a,b,c;
Point readPt(Point current);
void showPt(Point current);
float distance(Point first, Point second);
int main(){
int test;
cout << "Enter your first point.\n";
a = readPt(a);
cout << "Enter your second point.\n";
b = readPt(b);
showPt(a);
showPt(b);
test = distance(a, b);
return 0;
}
Point readPt(Point current){
char junk;
cin >> junk >> current.x >> junk >> current.y >> junk;
return current;
}
void showPt(Point current){
cout << "(" << current.x << "," << current.y << ")";
}
float distance(Point first, Point second){
return 1;
}