Fstream as a parameter

I am attempting to make a class with a function that will save data to a txt file. I thought that if i had a function with a filestream for a parameter i could just use the << operator and variable name to get it to type it in the file.
outputfile << "this is the id: " << id;

something like that... but even before i get to attempting that...


1
2
3
4
5
6
7
8
9
class Employee{
public:
  void saveEmployee(ofstream &emp_list);

private:
  unsigned int id;
  string f_name;
  string l_name;
 };

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

Employee::Employee(int i, string fn, string ln){
  id = i;
  f_name = fn;
  l_name = ln;
}

void Employee::saveEmployee(ofstream &emp_list){}


First error states that in the header it expected a ) on the line with the function name.
The second error says that Employee::saveEmployee is not a member of Employee
You are missing your prototype to the overloaded constructor in your class.
Topic archived. No new replies allowed.