err this is because...
i have something like this....
1 2 3 4 5 6 7 8 9 10 11 12 13 14
class A{
friendvoid B::setSalary(); //error cant find
private:
double salary;
};
class B:public A{
public:
void setSalary();
};
class C:public A{
friendvoid B::setSalary();
};
so, like this i can set all salary value that inherit class A....
its like the class A is Employee, class B and C is worker like clerk, manager, supervisor and accountant...
and accountant will set salary for them....
class A;
class B;
class C;
class A{
friendvoid B::setSalary(); //error cant find
private:
double salary;
};
class B:public A{
public:
void setSalary();
};
class C:public A{
friendvoid B::setSalary();
};
oops sorry. You'll want the class B to be declared before class A but because B is derived from A you'll run into another compilation error. It's a cyclical dependency. The only solutions i know be to either make B a member class of A or remove the inheritance from B. I would lean more towards not having B being derived from A (maybe you could add a higher inheritance level, if you really wanted to)
class A;
class B;
class C;
class Base
{
protected:
double salary;
};
class B: public Base
{
public:
void setSalary();
};
class A: public Base
{
friendvoid B::setSalary();
};
class C :public Base
{
friendvoid B::setSalary();
};
This has the same effect i think. So basically it's normally impossible to modify the salary from outside the class(e.g C can't change A's salary) but B(the accountant) can