
-----------------------------------
wtd
Wed Jun 16, 2004 10:27 pm

I fall further for O'Caml...
-----------------------------------
A trivial example to demonstrate some gorgeous code...

The goal: create a precompiled library containing a mutable_point class in a Point namespace/module.

point.h:
#include 
#include 
#include 

#ifndef __POINT__MUTABLE_POINT_H
#define __POINT__MUTABLE_POINT_H

namespace Point
{
	class mutable_point
	{
		protected:
			int x;
			int y;
		public:
			mutable_point(int init_x, int init_y);

			int get_x() const;
			int get_y() const;
			void set_x(int new_x);
			void set_y(int new_y);
			std::string to_str() const;
	};
}

#endif


point.cpp:
#include 
#include 
#include 
#include "point.h"

Point::mutable_point::mutable_point(int init_x, int init_y)
: x(init_x), y(init_y)
{ }

int Point::mutable_point::get_x() const
{
	return x;
}

int Point::mutable_point::get_y() const
{
	return y;
}

void Point::mutable_point::set_x(int new_x)
{
	x = new_x;
}

void Point::mutable_point::set_y(int new_y)
{
	y = new_y;
}

std::string Point::mutable_point::to_str() const
{
	std::stringstream out;
	out 