question about operator bool() const
when checking if an object has valid data do we need to check every private member of the class or only one?
For example:
In the OOP notes the conversion operator for bool only checks that one member is not zero or true
Like this:
Student::operator bool() const { return no != 0; }
Long story short do we need to check every member is true or only one for it to be considered valid data in an object?4 Replies
It’s how ever you deem a student to be a “valid student”
Depends on your logic ig
so say a student would not be valid if their grade is empty
then i would have to do something this..
Student::operator bool() const { return no != 0 && grade!= 0; }
??Yes basically
thank you!