|
-
January 31st, 2008, 12:31 AM
#4
Re: array of unknown length in a class
A node can be connected to any number of other nodes (all, some or none), so the question is how is this property best described in the node class?
Generally, the idea would be to have a container of pointers to the neighbour nodes. The node does not own its neighbours, so it will not be responsible for managing the memory of its neighbours.
Which container to use depends on what is needed. For example, do you often need random access to neighbour nodes (perhaps a vector will do)? Do you need to delete individual nodes (perhaps a container of weak_ptr is desirable)?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|