Newsgroups: comp.lang.c++
Path: utzoo!utgpu!cunews!csi.uottawa.ca!news
From: hitz@csi.uottawa.ca (Martin Hitz)
Subject: Re: Common data structures
Message-ID: <1991Jun19.163007.18398@csi.uottawa.ca>
Sender: news@csi.uottawa.ca
Nntp-Posting-Host: sim5
Organization: University of Ottawa
References: <TMB.91Jun18235004@volterra.ai.mit.edu>
Date: Wed, 19 Jun 91 16:30:07 GMT

In article <TMB.91Jun18235004@volterra.ai.mit.edu> tmb@ai.mit.edu (Thomas M. Breuel) writes:
>The problem is that C++'s version of polymorphism is rather inconvenient
>to use.
>
>In C++, you must introduce type names in templates and specify them at
>the point of use even if the compiler has enough information to infer
>this information (I don't have a C++ compiler with templates, so the
>syntax that your C++ implementation uses for templates may differ
>slightly from what I am using in this example):
>
>	template<base> list<base> map(base (*f)(base),list<base> l) ... ;
>	...
>	map<float>(f,l);
>
According to the ARM, the example should read:

	template<class base> list<base> map(base (*f)(base),list<base> l);
	
	float f (float);
	list<float> l;
	...
	map(f,l);

Note that at the call to map(), the compiler DOES infer the correct type.

Martin Hitz@csi.uottawa.ca
