1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
class point {
private: // why was it protected?
int x,y,z;
public:
point():x(0),y(0),z(0){};
point(int a,int b,int c):x(a),y(b),z(c){};
// could add copy constructor, but not needed...
//point(const point& p):x(p.x),y(p.y),z(p.z){};
};
class Sline { // no longer incorrectly inherits from point
protected:
point p1,p2;
public:
Sline() {}; // point constructors already init point members
Sline(point a,point b):p1(a), p2(b){}; // now using point copy constructor
};
int main()
{
point p1(1, 2, 3);
point p2(4, 5, 6);
point p3;
point p4(7, 8, 9);
Sline s1(p1, p2);
Sline s2(p3, p4);
Sline s3;
return 0;
}
|