This program works using Borland 4 but does not work when I compile it with Microsoft Visual C++.
[tt]
#include <iostream.h>
template<class T> T templat(T a,T b)
{
return((a > b) ? a: b);
}
float templat(float a,float b);
int templat(int a,int b);
void main(void)
{
float a = 2.335, b = 4.35;
cout << "FLOAT = " << a << " and " << b <<
templat(a,b) << endl;
int c = 2, d = 4;
cout << "INT = " << c << " and " << d <<
templat(c,d) << endl;
}[/tt]
Here is the Visual C++ error:
Linking...
templat.obj : error LNK2001: unresolved external symbol "int __cdecl templat(int,int)" (?templat@@YAHHH@Z)
templat.obj : error LNK2001: unresolved external symbol "float __cdecl templat(float,float)" (?templat@@YAMMM@Z)
Debug/templat.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
templat.exe - 3 error(s), 0 warning(s)
.
Any ideas why this is happening??
[tt]
#include <iostream.h>
template<class T> T templat(T a,T b)
{
return((a > b) ? a: b);
}
float templat(float a,float b);
int templat(int a,int b);
void main(void)
{
float a = 2.335, b = 4.35;
cout << "FLOAT = " << a << " and " << b <<
templat(a,b) << endl;
int c = 2, d = 4;
cout << "INT = " << c << " and " << d <<
templat(c,d) << endl;
}[/tt]
Here is the Visual C++ error:
Linking...
templat.obj : error LNK2001: unresolved external symbol "int __cdecl templat(int,int)" (?templat@@YAHHH@Z)
templat.obj : error LNK2001: unresolved external symbol "float __cdecl templat(float,float)" (?templat@@YAMMM@Z)
Debug/templat.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
templat.exe - 3 error(s), 0 warning(s)
.
Any ideas why this is happening??