Original Post
Greetings! Could someone please point out to me why the following code snippet does not work? When I call the templated constructor, which in turn calls the void parameter constructor, the m_TextColor variable remains un-initialized. I stepped through with the debugger. The templated constructor called the void parameter constructor, which does set the m_TextColor. As soon as I returned from the void parameter constructor back into the templated version, the m_TextColor variable switched back to being un-initialized. Why doesn't this work?
class Text
{
public:
Text();
template <typename T> Text (T Value)
{
Text();
SetText(value);
}
~Text();
void SetText(std::string value);
void SetText(int value);
void SetText(unsigned int value);
void SetText(float value);
//... etc ...
private:
unsigned char m_TextColor[4];
}
Text::Text()
{
m_TextColor[0] = 0;
m_TextColor[1] = 0;
m_TextColor[2] = 0;
m_TextColor[3] = 255;
}