Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top