Hi and thanks for reading.
I have a question about class design, this is my first effort in C++ so please be forgiving!
The problem: I have to design a class that represent a mechanical force element. Let's call this Force. Each Force has 6 components and some methods, to initialize and read some data, filling up the properties of the Force.
So my class looks something like this:
I wrote the various member definitions and all is fine and dandy.
Force(); // default constructor
~Force(); // default destructor
int readForceData(int, int, int, int, int, int, int);
In other words I'm able to initialize the Force object that I instantiate from this class, and I can verify that it contains all the data as read from file.
This force object also should be evaluated: each component should receive a numerical value and, based on the data for that particular component, it should return a value, something like F = k x where:
- k is part of the data that I read
- x is the input to the component
- F is the output value.
Seems pretty simple.
The problem is that I do not know if the results (6 values, one for each direction) should be part of my Force class. My intuition tells me that they should not private members and that they should go in a separate class alltogether.
If I do this how are the two distinct class supposed to work together? Can the computeForceResults receive an instance of the Force class?
int computeForceResults( ???? );
In other words, is it OK to do something like:
The compiler doesnt recognize that as valid.
int computeForceResults(Force &force);
Essentially I'm trying to understand the concept of class coupling and how to manage the separation between a class that contains the DATA and one that contains the RESULTS that are computed using that DATA.
Any help much appreciated!!!!
Thanks & regards,