100 to 150 words (i) Write a programme to sort an inter array of size 6 in desce
ID: 3782415 • Letter: 1
Question
100 to 150 words
(i) Write a programme to sort an inter array of size 6 in descending order using insertion sort algorithm.
(ii) Define a class named EMPLOYEE in C++ with the following description. Private Members:
E_Id – Integer
E_name – String of 25 characters
DOB – String of 12 characters
Basic – Float
DA – Float
HRA – Float
TOT_Salary – Float
Calculate-Salary () – it calculate the total salary as basic +DA+HRA where DA is 80% of basic and HRA is 15% of basic.
Public members
Accept () – it accepts E_Id, E_name, DOB and basic. Thereafter it called the calculate salary. Dispaly () – it displays the entire data. A constructer to initialize all integers and floats with 0.
(iii) Explain copy constructer with suitable example give proper class definition including the definition of copy constructor. How will this constructor be inwoked?
Explanation / Answer
(i)
(ii)
class EMPLOYEE
float Basic;
float DA;
float HRA;
float TOT_Salary;
Display();
(iii)
In copy constructor an object is created by initializing that object of the same class which was created preiviously. The copy constructor comprises of:
Initialize one object from another of the same type.
Copy an object to pass it as an argument to a function.
Copy an object to return it from a function.
Suppose a copy constructor is not defined in a class the compiler will define one implicitly. If some dynamic memory allocation is being done in the class having pointer variables, then copy constructor is necessary. The most common form of copy constructor is shown here:
Here, obj is a reference to an object that is being used to initialize another object.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.