VC++ 2010 can't run this..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <conio.h>
using namespace std;
template<class t>
t max(t k,t m)
{
	if(k>m)	return k;
	else	return m;
}
void main()
{
	int n1,n2;
	float f1,f2;
	char ch1,ch2;
	cout<<"Enter 1st integer:";	cin>>n1;
	cout<<"Enter 2nd integer:";	cin>>n2;
	cout<<"Enter 1st floating point number:";	cin>>f1;
	cout<<"Enter 2nd floating point number:";	cin>>f2;
	cout<<"Enter 1st character:";	cin>>ch1;
	cout<<"Enter 2nd character:";	cin>>ch2;
	cout<<"Maximum of integer="<<max(n1,n2);
	cout<<"\nMaximum of float="<<max(f1,f2);
	cout<<"\nMaximum charactet="<<max(ch1,ch2);
	getch();
}


my turbo c++ works but i want VC++ 2010....
<conio.h> and getc() are not a standard part of C++, though some compilers do support their use.

You could probably replace getch with a cin statement, though the behaviour is not quite the same.
I am using them in many codes but this is my 1st template code....when i remove template then its work.
Replace line 3 with:

1
2
using std::cout ;
using std::cin ;


Bringing the all of namespace std into the global namespace isn't recommended.
Topic archived. No new replies allowed.