Explain the following function header.
Void employee ::assign_values (int id,double salary)
#include<iostream>
using namespace std;
/*employee::assign_values(int id, double salary)
This function is a member function of class employee.
As its name suggests, it assigns two accepted parametres
id(maybe employee`s identificator) and salary(maybe employee`s
salary) to private members of class employee. Function doesn`t
return anything and has return type void
Consider intended using of this function*/
//Intended class:
class employee
{
int _id;
double _salary;
public:
//simple default constructor
employee():_id(0),_salary(0){}
//Declaration of function
assign_values(int id, double salary);
void display()
{
cout<<"ID= "<<_id<<" salary= "<<_salary;
}
};
//Definition of function
employee::assign_values(int id, double salary)
{
_id=id;
_salary=salary;
}
int main()
{
//Check work of function
employee e;
e.assign_values(123,755.8);
e.display();
}
Comments
Leave a comment