method overriding -text save function
this is a small segment using method overriding,,but shows error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <vector>
#include <iostream>
#include <string>
#include<fstream>
using namespace std;
class employee
{
public:
employee(string name,string last,int sal)
{mName =name;mLastName =last; mSalary= sal;}
virtual void printStats()
{
cout<<"Name ="<<mName<<endl<<"LastName ="<<mLastName<<endl<<"Salary ="<<mSalary<<endl;
}
virtual void save(ofstream& out)
{
out<<"Name ="<<mName<<endl;
out<<"Last Name ="<<mLastName<<endl;
out<<"mSalary ="<<endl;
}
protected:
string mName;
string mLastName;
int mSalary;
};
class manager :public employee
{
public:
manager(string name,string last,int sal,int meet,int vac):employee(name,last,sal)
{mMeet=meet; mVac =vac;}
void printStats(manager& mng)
{
employee::printStats();
cout<<"Meeting ="<<mMeet<<endl<<"Vacation ="<<mVac<<endl;
}
void save(ofstream& out)
{
//error line-- employee::save(ofstream& out);
out<<"Meeting ="<<mMeet<<endl;
out<<"Vacation ="<<mVac<<endl;
}
.........
|
error is::44 expected primary-expression before '&' token ""->in error line
change error line to this
yes, it got corrected..but can u tell me why was it wrong?
Topic archived. No new replies allowed.