class Variable
{
private:
int type;
union Value {
char sign;
int num;
} value;
public:
static const int SIGN = 1;
static const int NUM = 2;
Variable(char val)
{
type = SIGN;
value.sign = val;
}
Variable(int val)
{
type = NUM;
value.num = val;
}
Value get()
{
return value;
}
};
template<typename T> Variable::get()
{
return (T)value;
}
template<> Variable::get<int>()
{
return value.num;
}
template<> Variable::get<char>()
{
return value.sign;
}