The code that you are showing,
T show()
{
return(x>y)?x:y;
}
Is invalid, by looking at the class definition (have a look at the members!). You have defined only a and b to be properties in the class, x and y are not given to be of any type, and thus no defined in the given scope.
Quote:
only a and b worked.
That is because a and b are defined as properties (members) in your class of type
T
. That executes perfectly. Because compiler knows what type to use and where they are defined in the scope (as the members).
Solution to this problem is to just use the a and b names. Don't use the x and y; because that would require to change the class definition too!