I am working on developing a small finite element analysis program. Finite element analysis basically involves the discretization of a continuum into small manageable elements for structural analysis. The entire process is carried out with the help of matrix operations.
My problem is that using a for loop, I create a large number of elements based on the value entered by the user. For example if the user entered 10, then the loop would create 10 objects of the class Element. Now once the element matrices are formed, I need a function to add them all up.
Now how can I create a function in which I can pass all those element matrices for addition? All I know is that a fixed number of things can be passed to a function, but how can I pass any number of elements to a function?
An alternative approach (which is in some ways similar to putting them into an array) is to have a container class to hold the elements - you can then add the elements to the container class as you create them, then either have a function which acts on the container class memebers, or extend the contaienr class to add the function as a method.
Thanks for the reply guys. The container class and function with variable arguments both sound like good ideas. I will test them both and let you know my results here.