I have a problem though, the way I have done it (with the vector being a member of PipeElementClass and storing PipeElementClass objects) it means that every member of the vector pipeModel will contain another vector (again pipeModel) containing PipeElementClass objects which will also contain another vector and so on...
To get around this I was thinking about putting the vector in another class, but I would then have problems with overloading the operator functions (=, ==) as the implicit parameter (this) is no longer a PipeElementClass - and cant be passed more than one parameter if i'm not mistaken? Any thoughts on how I would overcome this?
lol, no you had that problem before you made the vector static :)
As you surmised every time you added an element to the vector that element itself contained another vector, although this vector had the potential to contain more objects and vectors in practice I imagine it would have 0 length and not contain any more objects and vectors. I did think of mentioning this in my last post.
However you have made the vector pipeModel static, this means that there is only 1 copy of the vector in memory and that all instances of the class use this 1 instance. So when you are adding elements to this vector you are not creating more vectors.
Because the vector is static you do not even need an instance of the class to access it you can always access it as
-
PipeElementClass::pipeModel.clear();
-
for instance.
You don't have to put the vector in another class, you could just declare it outside the class and a normal static variable, I'm not sure of the form (i.e. good or bad form) of doing this as opposed to having the vector as a static class member as I am mainly a C rather than C++ programmer.
You shouldn't get any problems with your = and == operator overrides as they are nothing to do with the vector. Just leave them as part of the PipeElementClass if you where to do this.