Thanks guys for all your kind heartedness.

Yeah, I got messed up with a lot of things in my previous program, like
missing the definition of one function and etc. I finally discovered a good
example on:
http://www.opensource.apple.com/darwinsource/Current/swig-4/swig/Examples/java/funcptr/index.html.
And I was able to make a workable example as following:

/* test.i */
%module test
%{
#include "test.h"
%}
%include "test.h"

%constant B (*F)( const A&)=f;
//let a=A(), b=B()
%template(ia) ex1<A>; // from Doc, works
%template(jab) ex2<A, B>; // jab(a,b) works
%template(kab) ex3<A, B>; // kab(a,b,1) works
%template(lab) ex4<A, B>; // lab(a,b,1,F) works
%template(fab) ex5<A, B>; // fab(a,b,1,F) ultimate goal


/* test.h */
#include<iostream>
using namespace std;

class A { };
class B { };
class E { };
B f( const A& ) { cout<<"This is a function map A to B"<<endl; return *(new
B); };
typedef B (*fp)( const A& );

template<class T> E ex1(T a, T b) { cout<<"ex1, one parameter
template"<<endl; return *(new E); }
// NOTE: simple template function

template<class T, class S> E ex2(T t, S s) { cout<<"ex2, two parameters
template"<<endl; return *(new E); }
// NOTE: this extends the one above with two template parameters

template<class T, class S> E ex3(T t, S s, int k) {
  cout<<"ex3, two parameters template plus an int argument"<<endl; return
*(new E); }
// NOTE: this extends the one above with additional integer argument

template<class T, class S> E ex4(T t, S s, int k, fp gp) {
  cout<<"ex4, two parameters template, an int argument and an func ptr
argument"<<endl;
  A a=A(); B b=gp(a); return *(new E); }
// NOTE: this extends the one above with one more function poiter argument

template <class C, class D>  E ex5(C c, D& d, int n, D (*g)(const C&)) {
  cout<<"ex5, two parameters template, an int argument and a template func
ptr argument"<<endl;
  g(c); return *(new E); }
// NOTE: this temaplate function TF takes a template function poiter as
argument, our ultimate goal

And currently I got my program work now. But the ex. in 5.4.9 still seems
not working. Anyway, so far good for me now. Maybe one last thing, currently
I need to put the definition and declaration of a template function all in
one file, otherwise I got undefined symbol error. How can I separate them
into a .h and .cpp file? The 'export' keyword which suggested in TCPL seems
do't work with gcc. Any comments?

Thanks a bunch already!

Charlie

	[[alternative HTML version deleted]]

