Topic: Pseudo typedef, Question from a novice
Author: stidev@gate.net (Solution Technology)
Date: 8 Feb 1995 22:46:04 GMT Raw View
Yann Langlais (langlais@corte-madera.geoquest.slb.com) wrote:
: Hi, I'm trying to create a small mathematical library and I'd like to create a fondamental
: pseudo type "scalar" independant from the memory representation (float, double, Complex, whatever...)
: but once specified, to inherit of the standard types such as -------^.
: I'd like scalar to behave like this:
Sounds like you might want to use templates, NOT typedefs!
Ken Walter
Author: langlais@corte-madera.geoquest.slb.com (Yann Langlais)
Date: 8 Feb 1995 00:04:52 GMT Raw View
Hi, I'm trying to create a small mathematical library and I'd like to create a fondamental
pseudo type "scalar" independant from the memory representation (float, double, Complex, whatever...)
but once specified, to inherit of the standard types such as -------^.
I'd like scalar to behave like this:
class Matrix
{
int
row, col;
scalar()
**Mat;
...
scalar()
}
void foo(..)
{
scalar(float)
k;
scalar(double)
j;
Matrix(float, 3, 3, ....)
TransformationMatrix;
...
}
This can't be done with a #define scalar(type) type neither by a typedef if I want to create different
instances of scalar with different standard types.
Is there a "smart" way to code such a thing, without having to recreate the world of C/C++ arithmetics???
Thanks,
--
|
Yann:-)
|
|
/ ||_____________|
| . | . .
\_____________/