Why not just code two plain separate classes?
Those classes should be relatively simple, and provide few functionalities... I would personally just code the two separately. Its not because they are somewhat similar in a way that they *have* to be united somehow. In this particular scenario, you don't really have a complex hierarchy where a pixel and a voxel belong to a common set of objects which belongs to another set of objects. You just have two partly similar classes.
Abstract base class... or a better way?
Quote:Original post by Xai
You cannot easily make such frameworks be embodied in base classes and polymorphics, because although a Point2D and Point3D could both derive from "Point" or "IPoint" ... almost no usefull work could be done on just "IPoint"s .. IE, you could not write function that took 2 Points and computed their distance, cause the function is different for 2D and 3D points.
You could use Alexandrescu's multimethods...
Quote:Original post by Max_Payne
Why not just code two plain separate classes?
Because then I would have to write overloaded methods of other classes that utilise pixels/voxels in computations. That's the whole point of templating... to save work down the track (somewhat).
Timkin
Quote:Original post by TimkinQuote:Original post by Max_Payne
Why not just code two plain separate classes?
Because then I would have to write overloaded methods of other classes that utilise pixels/voxels in computations. That's the whole point of templating... to save work down the track (somewhat).
Timkin
How much work have you saved so far :P ?
Quote:Original post by Max_Payne
How much work have you saved so far :P ?
By templating... quite a lot actually. Having to write two versions of every computational function (there are lots of them and they are LONG) would be a HUGE pain in the arse and a waste of time. Given the similarities of Pixels and Voxels, it takes little effort to hide the differences in a template class.
Anyway, I appreciate the point of view, I just don't agree that it's the correct way to go in this situation.
Cheers,
Timkin
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement