Answer to Question #268815 in C++ for Agola Shem

Question #268815

Explain the following function header.


Void employee ::assign_values (int id,double salary)


1
Expert's answer
2021-11-19T10:00:51-0500
#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();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS