I have a Binary Search Tree, I use template to add any class object to it.
I have a search function that returns said class object or NULL
Do I need to overload "=" to return this object ? I was hoping if I return object it would know to check: If same type replace values stored in LHS with values stored in RHS and if NULL mark first object as NULL.
Is my mistake maybe somewhere else (all I return is either full object or NULL, nothing else) or do I actually have to overload it ?
I have limited time (very) so how can I do this if needed ? and is it a fast process or will it involve a lot of modifications.
Sorry for lack of code but I can't think of any that would be relevant.
EDIT I also use a lot of NULL so can I return NULL into an object ? Example:
class Matrix {
private:
int col;
int line;
int value;
}
Matrix mat; mat = NULL;
Some code:
template <typename Type>
Type BST<Type>::search(int key) {
if (this->root == NULL)
return NULL;
else
return root->search(key);
Here Type is Matrix. Can I return NULL or go further with search and return Type, which again is Matrix?
Note: This is for homework purposes, leaking memory is my last concern. Simplicity and speed is by far my first problem