Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

//点を定義するクラス
class Point
{
public:
	double x, y;	//座標

public:
	void setPoint(double x, double y)
	{
		this->x = x;
		this->y = y;
	}
};

//距離を計算する
double distance(Point::Point P1, Point::Point P2)
{
	double dist;

	dist = sqrt( pow(P2.x - P1.x, 2) + pow(P2.y - P1.y, 2) );

	return dist;
}

int main(void)
{
	double x1, y1;
	double x2, y2;

	Point::Point P1;
	Point::Point P2;

	//座標入力
	cin >> x1 >> y1 >> x2 >> y2;
	P1.setPoint(x1, y1);
	P2.setPoint(x2, y2);
	
	cout << setprecision(9) << distance(P1, P2) << endl;

	return 0;
}




Compiler output:
a.cc:22:29: error: expected ')' before 'P1'
   22 | double distance(Point::Point P1, Point::Point P2)
      |                ~            ^~~
      |                             )
a.cc:22:46: error: expected ')' before 'P2'
   22 | double distance(Point::Point P1, Point::Point P2)
      |                ~                             ^~~
      |                                              )
a.cc:22:49: error: expression list treated as compound expression in initializer [-fpermissive]
   22 | double distance(Point::Point P1, Point::Point P2)
      |                                                 ^
a.cc:22:49: error: left operand of comma operator cannot resolve address of overloaded function
a.cc:22:49: error: no context to resolve type of 'Point::__ct '
a.cc: In function 'int main()':
a.cc:36:9: error: 'Point::__ct ' names the constructor, not the type
   36 |         Point::Point P1;
      |         ^~~~~
a.cc:36:21: error: expected ';' before 'P1'
   36 |         Point::Point P1;
      |                     ^~~
      |                     ;
a.cc:36:24: error: statement cannot resolve address of overloaded function
   36 |         Point::Point P1;
      |                        ^
a.cc:37:9: error: 'Point::__ct ' names the constructor, not the type
   37 |         Point::Point P2;
      |         ^~~~~
a.cc:37:21: error: expected ';' before 'P2'
   37 |         Point::Point P2;
      |                     ^~~
      |                     ;
a.cc:37:24: error: statement cannot resolve address of overloaded function
   37 |         Point::Point P2;
      |                        ^
a.cc:41:9: error: 'P1' was not declared in this scope; did you mean 'y1'?
   41 |         P1.setPoint(x1, y1);
      |         ^~
      |         y1
a.cc:42:9: error: 'P2' was not declared in this scope; did you mean 'y2'?
   42 |         P2.setPoint(x2, y2);
      |         ^~
      |         y2
a.cc:44:36: error: reference to 'distance' is ambiguous
   44 |         cout << setprecision(9) << distance(P1, P2) << endl;
      |                                    ^~~~~~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note: candidates are: 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
a.cc:22:8: note:                 'double distance'
   22 | double distance(Point::Point P1, Point::Point P2)
      |        ^~~~~~~~