Y
yangsuli
Hi, everybody;
I am a student who is taking the data structure course. When we are
learning the data structure LinkedList, I noticed that Java and C++
treated the type of the node of Linkedlist differently.
In STL, C++ actually publishes the typed of list_node:
class List{
protected:
typedef __list_node<T> list_node:
.....
}
But in Java, the class of LinkedListNode has package access, so the
user of LinkedList won't even see this node type.
Personally, I wound think the type of node is the implementation
detail, and the best practice is to hide it from the user.But I am
posting this message to see, is there any particular reason that C++
choose to publish the list_node type? Does this has something to do
with the difference in this two languages?
Any answer would be appreciated!
Thank you very much!
I am a student who is taking the data structure course. When we are
learning the data structure LinkedList, I noticed that Java and C++
treated the type of the node of Linkedlist differently.
In STL, C++ actually publishes the typed of list_node:
class List{
protected:
typedef __list_node<T> list_node:
.....
}
But in Java, the class of LinkedListNode has package access, so the
user of LinkedList won't even see this node type.
Personally, I wound think the type of node is the implementation
detail, and the best practice is to hide it from the user.But I am
posting this message to see, is there any particular reason that C++
choose to publish the list_node type? Does this has something to do
with the difference in this two languages?
Any answer would be appreciated!
Thank you very much!