I'm new to templates. I can't figure out what am i doing wrong:
#include "stdafx.h"
#include <iostream>
using namespace std;
template <typename T>
void inc(T* data)
{
(*T)++;
}
int main()
{
char x = 'x';
int b = 1602;
inc<char>(&x);
inc<int>(&b);
cout << x << ", " << b << endl;
int a = 0;
cin >> a;
return 0;
}
After compiling in VS2013 i got an error: Error 1 error C2275: 'T' : illegal use of this type as an expression
maybe you should:
template <typename T>
void inc(T* data)
{
(*data)++;
}