Hi,

Can't seem to get my head around templates enough to get something to work the way I want.

Essentially I'm trying to create a class member variable that can store other class objects.

Trying to achieve the following.
pseudo code;

Code:
class UI : public OtherClass
{
public:
    //other stuff
    template <typename Wild>
    struct VARIABLE_OBJECT
    {
        Wild Obj;
        VARIABLE_OBJECT(Wild obj) {};

    };
    std::vector<VARIABLE_OBJECT> m_Variable;
};

class Object1
{
    //functions, variables etc
};

class Object2
{
    //functions, variables etc
};


main()
{

    // here where m_Variable = VARIABLE_OBJECT either object1 or object2 type etc

    m_Variable.push_back(Object1);
    std::vector<VARIABLE_OBJECT>::iterator itObj;
    itObj = m_Variable.begin();

   for(itObj = m_Variable.begin() ;itObj !m_Variable.end();itObj++)
     itObj->items;

};
Where m_Variable is able to be different objects at runtime.

Maybe I'm going about it the wrong way, so open to suggestions but I'd like to do without inheritance for this with UI class.

Any pointers would be great thanks