S
Simon Elliott
Suppose I have a template:
template <class T> class bloggs
{
public:
T value;
};
Which I could use to store values of a particular type, eg
bloggs<unsigned short> b1;
b1.value = 1;
I want to extend this such that there's another data member, let's call
it bloggs_type, which is initialised to (some function of) the data
type I use when the class instance is created.
For example, if bloggs_type is a std::string:
bloggs<double> b2;
b2.value = 1.1;
std::cout << b2.bloggs_type << std::endl;
.... would output "double\n"
Is there any way I can do anything along those lines?
template <class T> class bloggs
{
public:
T value;
};
Which I could use to store values of a particular type, eg
bloggs<unsigned short> b1;
b1.value = 1;
I want to extend this such that there's another data member, let's call
it bloggs_type, which is initialised to (some function of) the data
type I use when the class instance is created.
For example, if bloggs_type is a std::string:
bloggs<double> b2;
b2.value = 1.1;
std::cout << b2.bloggs_type << std::endl;
.... would output "double\n"
Is there any way I can do anything along those lines?