Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

boost Variant

OteelOteel Posts: 2Member


Everything fine with Point class but Line class don't work correctly. The problem is when I choice line class it gives me value that I set up in default constructor and don't change value after called visitor.
Now I set up in default constructor in Line class [(1,2) (3,1)]... but I need that code gives me value of MyLine [(3,4,) (6,8)]

What wrong with Line class
last edition:
[CODE]
[CPP]// line.h
#ifndef LINE_H
#define LINE_H
#include "Shape.h"
#include "Point.h"
#include

class Line : public Shape
{
private:
Point start;
// string discrib;
Point end;

public:
//constructors and destructor
Line();
Line( Point& P_start, Point& P_end);
Line(const Line& line); // line copy constructor
~Line();

//getters and setters
void SetStart ( Point& SomePoint);
void SetEnd ( Point& SomePoint);
Point GetStart() const ;
Point GetEnd() const ;

Line& operator = ( const Line& l);
friend ostream& operator << (ostream& os , const Line& l);

//other useful methods
void ToString() const;
};

#endif

//point.h
#ifndef POINT_H
#define POINT_H

#include "Shape.h"
#include <ostream>
class Point : public Shape

{
private:
double Xcoord;
double Ycoord;

public:
Point();
Point (double xNew, double yNew);
Point( const Point& point); // copy constructor for Point
~Point();

void X( double Value);
void Y( double Value);
double X() const;
double Y() const;

Point& operator = ( const Point& p);
friend ostream& operator << (ostream& os , const Point& p);
void ToString() const;

};

#endif

#ifndef Shape_h
#define Shape_h
#include <string>
#include
using namespace std;

// shape.h
class Shape
{
protected:
int m_id; // Add a data member for an id number of type int.
public:
int id;
int ID() const; // return n_id data
Shape(); // initialises the id using a random number
Shape(const Shape &OtherShape); // copies the id member
Shape& operator = (const Shape &OtherShape); // copies the id member
virtual void ToString() const ; // returns the id as string e.g.

Comments

Sign In or Register to comment.