Please help me with this POO

I don't understand the problem, please help me !! It ougth to calculate the distance betwin two point (p1,p2)

"main.cpp"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "distancia.h"
void main ()
{
	Point p1,p2;

	cout <<"P1 -> ";
	p1.AskData();

	cout <<"P2 -> ";
	p2.AskData();

	double dist = p1.Distance(p2);

	cout << "The distance between P1 and P2 is:" << dist << endl;
	cout << "The end..." << endl;

}


"distancia.cpp"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "distancia.h"
#include <math.h>

void Point::AskData(void)
{
	cout <<"Coord. X = ";
	cin >> x;
	cout<<"\nCoord. Y = ";
	cin >> y;
}

double Point::Distance(Point p)
{
	double d = 0;
	d = sqrt((pow((p.x-x),2.0))+((pow((p.y-y),2.0))));
	system("pause");
	return d;
}


"distancia.h"
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;

class Point
{
	double x;
	double y;
public:
	void AskData(void);
	double Distance(Point p);
}
What problem do you have?
There are a lot of them, but they appear inside of "math.h" I don't know why it opens when I click twice in the problem and appear a strange algorim.

Other problem more normal but that I can't solve it is the following:
Error 54 error C2668: 'sqrt' : ambiguous call to overloaded function line 15

Error 56 error C3874: return type of 'main' should be 'int' instead of 'Point' line3

Warning 52 warning C4244: 'argument' : conversion from 'double' to 'int', line 15
There is a semicolon missing at the end of the header file:
4
5
6
7
8
9
10
11
class Point
{
	double x;
	double y;
public:
	void AskData(void);
	double Distance(Point p);
}; // semicolon was missing here 


The return type of main() should indeed be int (not void).
int main ()

I'm not sure about the sqrt() problem. Sometimes the compiler can't tell whether the argument is type float or double. But in this case everything is of type double already.
Ohhhhh thaks REALLY ALL THE PROBLEMS HAD DISAPPEAR !!!

=) =) =) =) =) =) =) IT WORKS!!!!!!!!!

I put here the correct code:

"main.cpp"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "distancia.h"
int main ()
{
	Point p1,p2;

	cout <<"P1 -> ";
	p1.AskData();

	cout <<"P2 -> ";
	p2.AskData();

	double dist = p1.Distance(p2);

	cout << "The distance between P1 and P2 is:" << dist << endl;
	cout << "The end..." << endl;

}


"distancia.cpp"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "distancia.h"
#include <math.h>

void Point::AskData(void)
{
	cout <<"Coord. X = ";
	cin >> x;
	cout<<"\nCoord. Y = ";
	cin >> y;
}

double Point::Distance(Point p)
{
	double d = 0;
	d = sqrt((pow((p.x-x),2.0))+((pow((p.y-y),2.0))));
	system("pause");
	return d;
}


"distancia.h"
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;

class Point
{
	double x;
	double y;
public:
	void AskData(void);
	double Distance(Point p);
};


Topic archived. No new replies allowed.