Get all nodes in the tree

I have a little problem with the following program

internal IEnumerable<T> GetItems<T>(string NodeName) where T : Root, new()
{
    var node = new T();
    return GetItems(NodeName, node).Cast<T>();
}

public IEnumerable<Root> GetItems(string NodeName, Root root)
{
    // do it
}

      

I would like to know how to change this in C ++ code. This is what I have tried

template<class T>
list<T> GetItems(string NodeName)
{
    auto node = new T();
    return GetItems(NodeName, node);
}

list<Root> GetItems(string NodeName, Root root)
{
    // do it
}

      

Now I would like to spoil it a little

typedef shared_ptr<Root> ROOT_PTR;
class SmallRoot:public Root{};
list<ROOT_PTR> GetItems(string NodeName, ROOT_PTR rootPtr)
{
    //do something and return a list of share pointers      
}

      

then I got stuck on how to redesign a template GetItems

for serving SmallRoot

classes

+3


source to share





All Articles