c++ - Composing objects of a class you inherit from? -
I have a square parameter, whose purpose is to represent possible values, hold a certain parameter (two key methods , GatewayValues () and Gettyval (Int Index)).
Often a logical parameter (parameter values are slightly flags) is represented by 2 or more examples of the parameter class (i.e. parameter may be 1 or 2, and 4, 8 is a parameter Rather than a parameter 5, 6, 9 or 10). To handle it, I would like to create a composite parameter class that includes parameters, and implement the getimmuvillus () and gateway () functions on the basis of the combination of those holding parameters.
And since composite permitter is combining the parameters to act as a single parameter, "composite permiter one parameter" relationship is understood. That's why I find myself in the situation where I have a class that collects the objects of that class which comes from it, which does not seem right, but at the same time, I do not know the higher level Why code composite parameters and parameters should not be enabled for the same type of treatment.
The only option I can think of is to write the composite parameter just to write the parameter, and the higher level code will only be related to the composite parameter. However, this is somewhat useless / general case is a composite parameter in which there is only one parameter.
Thoughts? Virtual Unsigned C GetValue (unsigned index) const {...}} class composite parameter: public parameter {public:
I have a class that creates objects in that class Which is received from it, which does not seem right now
Is not this the definition of composite?
(Parameter values are slightly flags)
Is it part of the design that I would be questioning perhaps the better name for the parameter FlagSet?
Behind the interface, it is OK to hide the bitwares, but it seems that he may have an heir to solve a problem with well-known solutions in basic computer science.
However, this is somewhat useless / B normal case would be a composite parameter with only one parameter
The overall pattern means Is that a leaf object represents a simple matter, an overall object represents a complex case, and the client code can treat both cases the same type of treatment. If your interface client code needs to be differentiated between two, or again via base class components, then you are not actually getting any value from using the pattern. For example, if your main concern is testing, then there may be a method in the base class:
bool test () const;
The implementation of the leaf class will look like this:
Bull Leafstarter :: Test () {Return _DoTest (); }
Composite class implementation will look like this:
bool CompositeTester :: test () {bool success = true; For (Int i = 0; I & lt; m_count; i ++) Success & amp; = M_components [i]. Test (); The success of the return; }
and the client will always use the code like this:
// tester can be a composite or a leaf, but we do not care : Bool testResult = tester.Test ();
I have used Loop to keep simple for example. In practice I will use STL instead.
Comments
Post a Comment