boost Variant

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:
[CPP]// line.h
#ifndef LINE_H
#define LINE_H
#include "Shape.h"
#include "Point.h"

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

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

//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;


#ifndef POINT_H
#define POINT_H

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

double Xcoord;
double Ycoord;

Point (double xNew, double yNew);
Point( const Point& point); // copy constructor for 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;



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

// shape.h
class Shape
int m_id; // Add a data member for an id number of type int.
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.


Sign In or Register to comment.

Howdy, Stranger!

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


In this Discussion