On Wed, Dec 18, 2002 at 03:30:12AM +0900, Florian Frank wrote:
> In Ruby you would program someting like this:
> 
> class Vector
> 
> ...
> 
> def print
> 	each { |elm| $stdout << elm << " " }
> 	$stdout << "\n" 
> end
> 
> end
> 
> You wouldn't have any problems with types.

In a real C++ application, I would have written:
  template<typename T>
  void print_vector(vector<T> const & v)
  {
    std::vector<T>::iterator it = v.begin();
    for(; it != v.end(); ++it)
    {
      std::cout << *it << std::endl;
    }
  }

but the purpose of the example wasn't to show good coding practice; it
was to show that type errors are real and can actually happen.  Whether
getting the compiler to find these errors is outweighed by the cost of
static typing is a separate issue.

Paul