I have a function like
void Element::setNodes(const BaseClass& input0, const BaseClass& input1)
This is called by passing a derived class.
setInputNodes(DerivedClass1, DerivedClass2)
The trouble I have is that I want to store the nodes in a vector. I have this
std::vector<std::shared_ptr<BaseClass>> m_inputNode;
and the function as
void Element::setNodes(const BaseClass& input0, const BaseClass& input1)
{
m_inputNode.push_back(input0);
m_inputNode.push_back(input1);
}
This doesn't work and I have to store it as a pointer otherwise I experience object slicing. Will I need to change the API and pass pointers? I want to change as little as possible.