smallPointExample[1]

# smallPointExample[1] - -p2 getx double Line:intercept...

This preview shows pages 1–2. Sign up to view the full content.

#include <iostream> using namespace std ; class Point{ private : double x ; double y ; public : Point( void ); Point( double , double ); double getx(); double gety(); void input( double , double ); }; Point :: Point (){ x= 0 ; y= 0 ; } Point :: Point ( double x1, double y1){ x=x1; y=y1; } double Point ::getx(){ return x; } double Point ::gety(){ return y; } void Point ::input( double x1, double y1){ x=x1; y=y1; } class Line{ private : Point p ; double s ; public : Line( Point , double ); Line( Point , Point ); double getx( double ); double gety( double ); double intercept(); bool isOntheLine( Point ); }; Line :: Line ( Point p1, double s1){ p=p1; s=s1; } Line :: Line ( Point p1, Point p2){

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
p=p1; s=(p1.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ()-p2. getx ()); } double Line ::intercept(){ return p. gety ()-s*p. getx (); } bool Line ::isOntheLine( Point p1){ if (p1. gety ()==s*p1. getx ()+ intercept ()) return true ; else return false ; } int main(){ double x,y; Point p[ 3 ]; for ( int i= ;i< 3 ;i++){ cout << "Give x coordinate for point #" << i+ 1 << ": " ; cin >> x; cout << "Give y coordinate for point #" << i+ 1 << ": " ; cin >> y; p[i]. input (x,y); } Line a(p[ ],p[ 1 ]); if (a. isOntheLine (p[ 2 ])) cout << "Point is on the line!" ; else cout << "Point is NOT on the line!" ; return ; }...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern