#include<iostream> using namespace std; class point { private: int x; int y; public: void setPoint(int xcoord,int ycoord) { x = xcoord; y = ycoord; } int getX() {return (x);} int getY() {return (y);} void showPoint() { cout << "(" << x << ","<< y <<")"; } }; int main() { point pt1,pt2; double dx, dy, dist; pt1.setPoint(-3,2); pt2.setPoint(2,5); dx = pt2.getX() - pt1.getX(); dy = pt2.getY() - pt1.getY(); dist = sqrt (dx*dx + dy*dy); cout << "The distance between two points"; pt1.showPoint(); cout << "and";pt2.showPoint(); cout << "is"<< dist << endl; return 0;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)