boost Variant - Programmers Heaven

Howdy, Stranger!

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

Categories

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.