You got "an error"? Okay, we have "an answer". Done. Case solved?
No? What is the exact error message then?
(We cannot simply click "compile" with the code that you did post, so our compilers
cannot immediately spit out a message.)
One might be able to transfer the problem to somebody else with: auto temp = myRoot;
BSTNode is a subtype of a dependent base class. myRoot is further a dependent name. The line may appear like this: typename BST<T>::BSTNode* temp = this->myRoot;
This is a little ugly - you may want to do some reading about the rules regarding the dependent name lookup mechanism.
There are two problems:
1.) you must specify this->myRoot because the name myRoot does not depend on a template parameter, and so it is checked according to the nondependent lookup rules at the point of declaration in the current context. Introducing the this pointer makes the name implicitly dependent.
2.) you must specify typename BST<T>::BSTNode* because BSTNode is again a dependent name (which is looked up when T becomes known); you must add typename to disambiguate in case there is a template specialization for a given T where BST<T>::BSTNode does not name a type.