I have a member function in my base class which takes argument by reference:
// Base
template<class Data, class Variable_Type = double>
class Parallel_Data
{
...
void FuncA(Data& data, int& Global_ID)
{Data_Local.push_back(data); Local_To_Global_ID.push_back(Global_ID);};
}
// Derived
class Derived: public Parallel_Data<Atom_Placed>
The problem is when I try to call that function in the derived member functions
Push_Back_This_CPU(Atom_Placed(Position_Atom), Global_ID);
I get following error
no known conversion for argument 1 from ‘Atom_Placed’ to ‘Atom_Placed&’
I am just trying to pass the argument by reference and don’t know why it wants to convert?
Temporaries like
Atom_Placed(Position_Atom)cannot bind to non-const references such as the parameterAtom_Place&. The reason is that they are temporary objects and will die any moment now.You could make a local variable of type
Atom_Placedand pass that to the functionPush_Back_This_CPU