In this scenario, you're defining a binary tree class template (BT) and a class template (BE) that represents an element of the tree. You encounter a peculiar requirement to declare the friend template as BT instead of BT
Initially, you attempt to declare the friend template as template
When you declare template
If you wish to restrict the friend relationship to only those instantiations of BT that utilize the same template argument as BE, you should declare the friend as follows:
templatefriend class bar ;
In your specific case, declaring friend class bar
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3