Home > Back-end >  C program BUG
C program BUG

Time:10-04

# # ifndef DECLARE_CLASS_H_
# define DECLARE_CLASS_H_
#include
#include
Using STD: : string;
The class abstr_emp
{
Private:
String fname;
String lname;
String job;
Public:
Abstr_emp (void);
Abstr_emp (const string & amp; Fn, const string & amp; Ln, const string & amp; J);
Virtual void ShowAll (void) const;
Virtual void SetAll (void);
Friend STD: : ostream & amp; Operator<(STD: : ostream & amp; OS, const abstr_emp & amp; E);
Virtual ~ abstr_emp (void)=0;//virtual base class
};

The class employee: public abstr_emp
{
Public:
The employee (void);
The employee (const string & amp; Fn, const string & amp; Ln, const string & amp; J);
Virtual void ShowAll (void) const;
Virtual void SetAll (void);

};

The class manager: virtual public abstr_emp
{
Private:
Int inchargeof;
Protected:
Int InChargeOf (void) const {return InChargeOf; }
Int & amp; InChargeOf (void) {return InChargeOf; }
Public:
Manager (void);
Manager (const string & amp; Fn, const string & amp; Ln, const string & amp; Int j, ico=0);
Manager (const abstr_emp & amp; E, int ico);
Manager (const manager & amp; M);
Virtual void ShowAll (void) const;
Virtual void SetAll (void);
};

The class fink: public virtual abstr_emp
{
Private:
String reportsto;
Protected:
Const string ReportsTo (void) const {return ReportsTo; }
String & amp; ReportsTo (void) {return ReportsTo; }
Public:
Fink (void);
Fink (const string & amp; Fn, const string & amp; Ln, const string & amp; J, const string & amp; Rpo);
Fink (const abstr_emp & amp; E, const string & amp; Rpo);
Fink (const fink & amp; E);
Virtual void ShowAll (void) const;
Virtual void SetAll (void);
};
The class highfink: public manager, public fink
{
Public:
Highfink ();
Highfink (const string & amp; Fn, const string & amp; Ln, const string & amp; J, const string & amp; Rpo, int ico);
Highfink (const abstr_emp & amp; E, const string & amp; Rpo, int ico);
Highfink (const fink & amp; F, int ico);
Highfink (const manager & amp; M, const string & amp; Rpo);
Highfink (const highfink & amp; h);
Virtual void ShowAll (void) const;
Virtual void SetAll (void);
};
# endif//DECLARE_CLASS_H_





#include
# include "declare_class. H"
Using STD: : cout;
Using STD: : endl;
Using STD: : cin;

//class base class
Abstr_emp: : abstr_emp (void) : fname (" none "), lname (" none "), the job (" NULL ")
{
}
Abstr_emp: : abstr_emp (const string & amp; Fn, const string & amp; Ln, const string & amp; J)
: fname (fn), lname (ln), job (j)
{
}
Void abstr_emp: : ShowAll (void) const
{
cout<" Fname: "& lt; cout<" Lname: "& lt; cout<" Job: "& lt; }
Void abstr_emp: : SetAll (void)
{

cout<" Enter your fname: ";
Cin. The get ();
Getline (cin, fname);
cout<" Enter your lname: ";
Getline (cin, lname);
cout<" Enter your job: ";
Getline (cin, job);

}
STD: : ostream & amp; Operator<(STD: : ostream & amp; OS, const abstr_emp & amp; E)
{
cout<" Fname: "& lt; cout<" Lname: "& lt; cout<" Job: "& lt; Return the OS;
}
Abstr_emp: : ~ abstr_emp (void) {}//virtual base class


//class employee
Employee: the employee (void) : abstr_emp ()
{
}
Employee: : the employee (const string & amp; Fn, const string & amp; Ln, const string & amp; J) : abstr_emp (fn, ln, j)
{
}
Void the employee: : ShowAll (void) const
{
Abstr_emp: : ShowAll ();
}
Void the employee: : SetAll (void)
{
Abstr_emp: : SetAll ();
}

//class manager
Manager: the manager (void) : abstr_emp (), inchargeof (0)
{
}
Manager: the manager (const string & amp; Fn, const string & amp; Ln, const string & amp; Int j, ico)
: abstr_emp (fn, ln, j), inchargeof (ico)
{
}
Manager: the manager (const abstr_emp & amp; E, int ico) : abstr_emp (e), inchargeof (ico)
{
}
Manager: the manager (const manager & amp; (m), m) : abstr_emp inchargeof (m.i nchargeof)
{
}
Void manager: : ShowAll (void) const
{
Abstr_emp: : ShowAll ();
cout<" Inchargeof: "& lt; }
Void manager: : SetAll (void)
{
Abstr_emp: : SetAll ();
cout<" Enter the manager 's inchargeof: ";
Cin> InChargeOf ();
While (cin. The get ()! )
='\ n'continue;
}


//class fink
Fink: : fink (void) : abstr_emp (), reportsto (0)
{
}
Fink: : fink (const string & amp; Fn, const string & amp; Ln, const string & amp; J, const string & amp; Rpo)
: abstr_emp (fn, ln, j), reportsto (rpo)
{
}

Fink: : fink (const abstr_emp & amp; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related