Re: Problem with output
sam wrote:
I written the program as follows :-
<snip>
I read the thread about 13:00 GMT and posted here anyway. I modernized and
standardized the code and it compiles, no messages, and runs and produces
the expected outpit on the DevC package.
---revised code---
#include<iostream>
#include<conio.h>
template <class t>
t fun(t a, t b)
{t s;
s=a+b;
return (s);
}
int main()
{
//clrscr();
int x,y,z=0;
x=4;y=5;
z=fun<int>(x,y);
std::cout<<z;
getch();
}
/*
When I compiled this program on Turbo c++ 3.0 , I am
getting syntax error and also i got error as follows :-
x is assigned to a value that is never used and
y is assigned to a value that is never used ,
Please help me out in this.
*/
I hope this list is complete. remove the .h on iostream. conio.h is OK on
DevC but not clrscr, remove it. change return type of main from void to
int, add std:: to cout call.
I had a fair amount of success using templates on TC 3.1 for windows. You
don't mention what the syntax error was, nothing leaps out at me. Unless
there is some overriding reason I would abandon Borland, it is/was nice but
it is just a question of time until some big problems comes up. DevC aka
MingW aka Bloodshed is an easy transition. (aka used loosely). The
debugger is nothing to write home about, docs are pretty sparse. Other than
that it seems OK for light duty work.