#include <iostream>
#include <cstdarg>
 
using namespace std;
 
enum types
{
    INT,
    DOUBLE,
    CHAR,
    STRING
};
 
struct multitype
{
    types type;
 
    union
    {
        int         i;
        double      d;
        char        c;
        const char *s;
    } val;
 
    
};
 
multitype mt(int i)
    {
        multitype res;
        res.type = INT;
        res.val.i = i;
        return res;
    }
 
multitype mt(double d)
    {
        multitype res;
        res.type = DOUBLE;
        res.val.d = d;
        return res;
    }
 
multitype mt(char c)
    {
        multitype res;
        res.type = CHAR;
        res.val.c = c;
        return res;
    }
 
multitype mt(const char *s)
    {
        multitype res;
        res.type = STRING;
        res.val.s = s;
        return res;
    }
 
void print(int n, ...)
{
    va_list ap;
 
    va_start(ap, n);
 
    for (int i = 0; i < n; i++)
    {
        multitype x(va_arg(ap, multitype));
 
        switch (x.type)
        {
        case INT:
            cout << x.val.i << endl;
            break;
        case DOUBLE:
            cout << x.val.d << endl;
            break;
        case CHAR:
            cout << x.val.c << endl;
            break;
        case STRING:
            cout << x.val.s << endl;
            break;
        }
    }
 
    va_end(ap);
}
 
int main()
{
    print(4, mt(2), mt(4.2), mt('a'), mt("Hello"));
}