@
L B
OK, as well as that, would you overload the interface functions so they take references to various types - that way avoiding being restricted to one return type?
1 2 3 4 5 6 7 8
|
void CRectangle::Area(std::size_t& TheArea){TheArea = static_cast<std::size_t>m_Area;}
void CRectangle::Area(float& TheArea){TheArea = static_cast<float>m_Area;}
void CRectangle::Area(double& TheArea){TheArea = m_Area;}
double MyArea = 0.0;
CRectangle MyRect;
MyRect.Area(MyArea);
|
Or alternatively, might it be better to use templates for everything? Which goes right back to the example
Cubbi had shown us of the Boost Library Points, Lines etc, much earlier.
I keep think of a CAD (Computer Aided Drawing ) application, in which each type of Drawing Object needs access to all the other Drawing object types' data, because the user is frequently drawing from one object to another.
Having the templated get functions is great because one can choose exactly which data they want from the object. They may not want all of it for a complex object.
I am guessing that one might use a Mediator DP to restrict the coupling from each Drawing Object to the Mediator class, rather than to the entire application. But this probably means retrieving all the info for a particular object.
The other thing about CAD dwg objects is that IMO their underlying type will always be double, and I don't see a reason for that changing at any time. Sure there are selection boxes that have to have unsigned values to do with mouse co-ords, but that is known in advance & the GUI framework already has Rectangle classes for that type of purpose.
Hell, I think I am getting nearer to a complete understanding, after all this discussion 8<)