cpp2html 0.1-alpha © 2002 Andrea Leofreddi. To get the source click here

// 1.2: funzioni template
#include <iostream>

using namespace std;

class A {
	private:
		int dato;
	public:
		A(int n) : dato(n) { };
		void stampa() const { cout << dato << endl; };
};

class B {
	private:
		int x;
	public:
		B(int n) : x(n) { };
		void stampa() const { cout << x << endl; };
};

class C {
};

template<class T> void stampa(const T &r) {
	r.stampa();
}

void main() {
	A a(3);
	B b(9);
	C c;

	stampa(a);
	stampa(b);
	//stampa(c); // ERRORE
}