For appropriate use of member pointer vs. member variable, see this discussion.
Now, here is what you can do with the Edge
class with regard to the "zero" value:
Change the constructor of Edge
to read:
Edge(int length=0, int width=0)
This way when Edge
is default constructed with Edge e1
(or implicitly with Node n1
), that constructor will be matched and the default values as specified will be used.
I'd say an edge of length 0 and width 0 makes perfect sense as a "zero" edge.
I've only listed one way to define default values for the constructor. There is additional discussion on the topic here.