Ryan
2013-04-04 07:19:36 UTC
// Template finds half of any value
#include
#include
#include
using namespace std;
template
double half(T)
{
double h = x * 1.0 / 2;
return(T);
}
void main()
{
int a = 47;
double b= 39.25;
cout<<"Half of "< cout<<"Half of "< getch();
}
Errors:
1>------ Build started: Project: hello boys, Configuration: Debug Win32 ------
1> Lab 10.1.cpp
1>Lab 10.1.cpp(20): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\conio.h(128) : see declaration of 'getch'
1>Lab 10.1.cpp(10): error C2065: 'x' : undeclared identifier
1> Lab 10.1.cpp(18) : see reference to function template instantiation 'double half
1> with
1> [
1> T=int
1> ]
1>Lab 10.1.cpp(11): error C2059: syntax error : ';'
1>Lab 10.1.cpp(10): error C2065: 'x' : undeclared identifier
1> Lab 10.1.cpp(19) : see reference to function template instantiation 'double half
1> with
1> [
1> T=double
1> ]
1>Lab 10.1.cpp(11): error C2059: syntax error : ';'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========