I am working on Michael Laszlo's book on computational geometry and have become confused with an unsual kind of template class constructors syntax he has used.
1st code
template<class T> class ListNode :public Node{
public:
T _val;
ListNode(T val);
friend class List<T>;
};
template class<T> ListNode::ListNode(T val) : // shouldn't this be template <class T> ListNode <T>::ListNode(T val)
_val(val)
{
}
Question
Shouldn't the syntax be ListNode <T>::ListNode(T val)
instead of ListNode ::ListNode(T val)
?
The code you provided will not compile. You're absolutely right that it should be ListNode<T>::ListNode(T val)
(although passing by value is debatable). If you check the book's errata, you might be able to find this in there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.