I am writing a fuzzy logic header in c++ and tried to do the following.
typedef float fuzzy;
fuzzy operator !();
To which the compiler had this to say.
error: ‘fuzzy operator!()’ must have an argument of class or enumerated type
I know that I could write a class that would handle this (probably mush faster than it will take to ask this question), but that seems like overkill as such a class would literally have only 1 data member and only constructor and assignment member functions. All of which are superfluous as there is only 1 data member and it would be handled as if it were a float. The other operators would presumably be implemented as non-member functions. So the class would essentially be a float, except for it's customized logical and bitwise operators.
Is it possible to use a typedef to create a customized version of a built-in (a sort of pseudo class)? From what I can find, typedefs are mostly used to reduce the number of places a programmer might have to change types in the event that some environment defines/handles it's types differently.
Maybe I'm crazy, but this seems like one of the most logical and desirable ways to use a typedef. Is there some reason why this is a bad idea, or just not possible?