Pergunta

I am having problems declaring a class function from the header file, am not sure how it should be formatted in the header. The purpose of this is to save class object data into a file, to be able to read back in later.

employee.h

void writedata(ofstream);

employee.cpp

void Employee::writedata(ofstream& employeewrite)
{
}

Employeewrite is the ostream object I declared in main

main.cpp

ofstream employeewrite("c:\\test\test.txt");

Thanks for any help.

Foi útil?

Solução

You're declaring writedata to take a ofstream in your header, but defining it to take an ofstream& (a reference to an ofstream) in the source file. Make them match up.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top