The code below of an overloaded member functions looks bloated:
void MyClass
::writeListToXml(const QList<int>
&list,
const QString &name
) {
foreach(int i, list) {
xml_writer
->writeTextElement
(name,
QString::number(i
));
}
}
void MyClass
::writeListToXml(const QList<double>
&list,
const QString &name
) {
foreach(double i, list) {
xml_writer
->writeTextElement
(name,
QString::number(i
));
}
}
void MyClass::writeListToXml(const QList<int> &list, const QString &name)
{
foreach(int i, list) {
xml_writer->writeTextElement(name, QString::number(i));
}
}
void MyClass::writeListToXml(const QList<double> &list, const QString &name)
{
foreach(double i, list) {
xml_writer->writeTextElement(name, QString::number(i));
}
}
To copy to clipboard, switch view to plain text mode
How could i pack them together?
Thanks!
Bookmarks