Linking Objects between Vectors - Best method
Hi everyone, I have a question about how to best proceed on a program I'm trying to make as an exercise for myself. I'm not asking for code, but rather for the best method to get me started. I'm pretty new to all this so my explanation might be very confusing.
So basicly I want to make a program which allows the user to insert a number of nodes in an X-Y plane. So every node would be an object, with 2 int values assigned. So I would first have to define the class nodes and then make a vector container out of it to allow the users to add/delete as many nodes as they want.
As a second part I'd like to allow the user to make a number of lines, which are objects, consisting out of 2 nodes as defined above. The class lines would also allow a function to calculate length depending on the 2 nodes that are used. Again I'd need to make a vector container out of it as to allow for as many lines as the user wants.
So how I see it:
1. define class nodes
2. create vector consisting of nodes
3. define class lines, with 2 nodes and one function which calculates the length
4. create a vector consisting of lines
However, step 3 is unclear to me. How can you link all this together, so that when you change a node coördinates, the lines will know this happened and the length function will use the correct node coördinates.