I'm trying to call a nonmember function of a derived class from a base class, but getting this error:
error: no matching function for call to 'generate_vectorlist(const char&)'
Here's the relevant code snippets from the base class:
//Element.cpp
#include "Vector.h"
...
string outfile;
cin >> outfile;
const char* outfile_name = outfile.c_str();
generate_vectorlist(*outfile_name); //ERROR
...
and the derived class (this is a template class, so everything's in the header):
//Vector.h
template <class T>
void generate_vectorlist(const char* outfile_name = "input.txt" )
{
std::ofstream vectorlist(outfile_name);
if (vectorlist.is_open())
for (Element::vciter iter = Element::vectors.begin(); iter!=Element::vectors.end(); iter++)
{
Vector<T>* a = new Vector<T>(*iter);
vectorlist << a->getx() << '\t' << a->gety() << '\t'<< a->getz() << std::endl;
delete a;
}
else { std::cout << outfile_name << " cannot be opened." << std::endl;}
vectorlist.close();
}
My guess is there's just a small syntax thing that I'm missing. Any ideas?