M
ma740988
In an attempt to write generic code for data types int, float,
double..., a template seems like the most viable solution.
So now, the .h file contains the prototypes for the functions and the
cpp contains the definitions of the functions. The compiler should
give errors - rightly so - if template<class T> is not specified
before the prototype AND before the header of the definition in the
..cpp.
template<class T>
T DoASpecialThing (T Number);
Then it dawned on me. Perhaps I could make the above definition look
'nicer'. As a result one thought involved creating a typedef for the
template defintions. Akin to (WARNING. I KNOW THIS DOESN'T WORK)
typedef template <class T>
In the end, I'm opting to create/would like to create my own sort of
"data type" that accepts unknowns, like template. Organized code is
one of the goals so I suspect a typedef would be option 1 or ..
Example(s) appreaciated.
It appears to me that I'm might be threading down the path of 'traits'
or specilization. Both of which I'm not savy on, nonetheless ...
double..., a template seems like the most viable solution.
So now, the .h file contains the prototypes for the functions and the
cpp contains the definitions of the functions. The compiler should
give errors - rightly so - if template<class T> is not specified
before the prototype AND before the header of the definition in the
..cpp.
template<class T>
T DoASpecialThing (T Number);
Then it dawned on me. Perhaps I could make the above definition look
'nicer'. As a result one thought involved creating a typedef for the
template defintions. Akin to (WARNING. I KNOW THIS DOESN'T WORK)
typedef template <class T>
In the end, I'm opting to create/would like to create my own sort of
"data type" that accepts unknowns, like template. Organized code is
one of the goals so I suspect a typedef would be option 1 or ..
Example(s) appreaciated.
It appears to me that I'm might be threading down the path of 'traits'
or specilization. Both of which I'm not savy on, nonetheless ...