Podejrzewam, że problem do rozwiązania jest trywialny, niestety ja już straciłem cierpliwość. Przy próbie kompilacji występuje o to takie komunikaty:
error C2440: 'return' : cannot convert from 'std::basic_ostream<_Elem,_Traits>' to 'int'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> szablonfunkcji.cpp(17) : see reference to function template instantiation 'T f<int>(T *)' being compiled
1> with
1> [
1> T=int
1> ]
1>
1>Build FAILED.
TO MÓJ KOD:
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
template < class T >
T f(T* arg){
T a = *arg;
return cout << a << endl;
}
int main()
{
int a = 221;
int* a2 = &a;
f(a2);
getch();
}