Quote Originally Posted by Paul McKenzie View Post
The cpp files:

Here is Shape.cpp:
Code:
#include <cstdlib>
#include "Shape.h"

Shape::Shape( ) : m_id(rand())
{ }

int Shape::ID() const
{ return m_id; }

void Shape::ToString( ) 
{ }
Here is Point.cpp:
Code:
#include <iostream>
#include "Point.h"

using namespace std;

Point::Point( ) { }

Point::Point( double xNew, double yNew ) :Xcoord(xNew), Ycoord(yNew) 
{ }

Point::Point( const Point &point ) : Xcoord(point.Xcoord), Ycoord(point.Ycoord)
{ }

void Point::X( double Value ) 
{  Xcoord = Value; }

void Point::Y( double Value )
{ Ycoord = Value; }

double Point::X( ) const
{ return Xcoord; }

double Point::Y( ) const
{ return Ycoord; }

void Point::ToString( )
{
    cout << "( " << X() << "," << Y() << " )";
}

ostream & operator <<( ostream &os, const Point &p )
{
    os << "[" << p.X() << "," << p.Y() << "]";
    return os;
}
Here is Line.cpp
Code:
#include <iostream>
#include "line.h"

using namespace std;

Line::Line( ) { }

Line::Line( const Point& P_start, const Point& P_end ) : start(P_start), end(P_end) { }

void Line::SetStart( const Point& SomePoint )
{ start = SomePoint; }

void Line::SetEnd( const Point& SomePoint )
{ end = SomePoint; }

Point Line::GetStart() const
{ return start; }

Point Line::GetEnd() const
{ return end; }

ostream & operator <<( ostream &os, const Line &l )
{
    os << "[" << l.GetStart() << "," << l.GetEnd() << "]";
    return os;
}

void Line::ToString( ) // returns the line as string
{
    cout << "[["
        << start << "," << end << "]]" << endl;
}
I didn't compile all of this, but the point is that the code is simpler. There are no copy constructors or assignment operators to mess up or other unnecessary functions.

The next step for you is to take a simple main() program that uses the boost classes and make sure you know how to use them before you write or call other functions that do something much more complex. If you believe you can use boost::any correctly and call of these visitor pattern functions, then there really isn't any need for you to ask us to debug your code, since these items assume you're an intermediate to advanced C++ programmer.

Regards,

Paul McKenzie
Thank you very much !