I'm trying to overload operator! for my class, but I receive error: 'void myClass<T>::operator!(const char&)' must take 'void'.
Is it possible to overload operator! ?
So I have a problem. I have to make class Not to simulate not gate.
No problem with operator! when the input is a bool, but there could be also the input 'x' (undefined). When I receive in input a character, my idea was to overload operator! to give in output the same character 'x'.
> I have to make class 'Not' to simulate 'not' gate.
I suppose that you'll also have classes for others operations, like 'And', 'Or', 'Xor'
think how they will be used
note that there is no operator overload
each kind of gate has some Inputs, and perform an operation based on their state
An alternative is to have member functions to the operations, then you may write
1 2 3
Input A, B;
(A.Or(B)).And( (B.And(True)).Not() );
(A + B) * !(B*True); //with operator overloading
that may be done like
1 2 3 4 5 6 7
class Input{
char state; //0, 1, 'x'
public:
Input Or(Input b) const; //as a member function
Input Not() const;
};
Input And(Input a, Input b); //as a non-member function (¿friend?)
note the signatures, they take Input objects and return an Input object
if you want to overload the operators they will follow the same signature