Like this,
bool isEmpty() const { return root==NULL; }
This is isEmpty function, test if the BST is empty or not.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It indicates that the function does not modify any of the members of that class.
Usually, the Interface/declaration(through header file) is made available to the users of the class/functions and not the implementation,So the
constmakes it clear to the user that the function does not modify any members.Adding the
constalso makes the user of the function aware that thisconstmember functions should be used when you have anconstobject.You cannot call normal member function on aconstobject of that class,it will result in a compiler error.That is the reason that the function is marked
consteven if it is empty.It indicates a contract between the function implementer and the user of the function.