I have to create a project that includes the template function sort3. it must display floats small = 12.3, mid =5.4, big =9.1. I keep getting unqualified id errors. what am i doing wrong?
[code]
template (class T)
class floats
{
T small, mid, big;
public:
floats (T small, T mid, T big);
{
a=first;
b=second;
c=third;
T sort3();
};
template (class T)
T floats(T)::sort3()
{
T sort3;
sort3= a>b, b>c a : b; b : c;
return sort3;
}
1. you are using a,b,c without declaring them.
2. You are using first, second, third without declaring them
3. You are taking small, mid, bit as parameters (which is a little confusing)
4. Your floats class is missing a }
5. a>b, b>c a : b; b: c; is not c++
6. return sort3 doesn't make much sense in C++, I assume you are coming from Visual Basic.
^
1. You don't assure the invariant (the client may modify the values as he pleases)
2. Your swap() member function does not use/modify the state of the object.
3. You could use std::swap() instead of losing time codifying your own.
4. You don't use initialization list, so the template type must have a default constructor.
5. `floats' is not a descriptive name.