This is a forward declaration:
template <class tipo>
void dar( tipo dato );
And this is supposed to be the definition:
void dar( tipo dato ){
cout<<"el dato es: "<<dato;
}
But it isn't. Instead it's a function (not a function template) taking a tipo
by value. There is no type called tipo
in the program.
You need to make tipo
a template parameter:
template <class tipo>
void dar( tipo dato ){
cout<<"el dato es: "<<dato;
}
An easier way to do it is to provide the definition directly at the beginning of the program and skip the forward declaration:
#include <iostream>
// using namespace std; // don't use this even though the video used it. See:
// https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
template <class tipo>
void dar( tipo dato ) {
std::cout << "el dato es: " << dato << '\n';
}
int main(){
int dat1 = 345;
float dat2 = 4.435;
char dat3 = 'a';
dar( dat1 );
dar( dat2 );
dar( dat3 );
}