This:
Nontype template argument must be of scalar type
is the error that I get when I try to build this program using Turbo C++ 4.5. I have got some errors like:
non-type template argument refers to function that does not have linkage
But this error is entirely new for me. What is wrong in the code?
#include<iostream.h>
template<class T1=int,class T2=int>
class tempex
{
T1 a;
T2 b;
public:
tempex(T1 x,T2 y)
{
a=x;
b=y;
}
void show()
{
cout<<"A= \t"<<a<<"\tB=\t"<<b;
}
};
int main()
{
tempex <float,int> te1(1.23,123);
te1.show();
return 0;
}
Turbo C++ 4.5 is from 1994!!! C++ wasn't even standardised until 1998. It is little surprise, then, that your antiquated software cannot parse this [almost] valid C++ program.
What else happened in 1994? Hmm, let's see:
You really ought to use something from this century, like GCC 4.9, or Microsoft Visual Studio 2013; you could have used an "old" compiler like GCC 4.1 or Visual Studio 2005, and it would still be a decade younger than the dinosaur you've dredged up. Where did you even find it?!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With