help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warning with function templates [Ooops, fix]


From: BobR
Subject: Re: warning with function templates [Ooops, fix]
Date: Sun, 17 Jul 2005 01:01:58 GMT

BobR wrote in message ...
>
>template <class T>
>T GetValue(T t) {  // <--note the parms
>    if (t == 1)    // <-- note the '==' compare, NOT '=' assignment.
>        return 1;
>    else
>        return 2.55;
>}

NOPE! That won't fix it!

template <class T>
T GetValue(T t) {
    if (t == 1)
        return 1;
    else
        return T(2.55);
    }

....compiled without warning.
output:

Int a : 1

Double b: 2.55

--
Bob R
POVrookie





reply via email to

[Prev in Thread] Current Thread [Next in Thread]