You have been developing a small commercial Software for numeric operations. You are working on the calculation of areas and volume of different shapes. Based on your software complete these tasks:
a) Create a function template named as shape() that accepts three arguments in such a way that first and second will be the dimension like base and height and the third will be the name of the shape. The shape() function displays the dimension values and the area of the shape. The function returns the area to the calling program; the area is the same data type as the parameter. [Note: Design a main program such that, it input the values of only those shapes whose area is computable on the bases of base and height only]
b) Create another function template named as show_master()that accepts two arguments. The first is index and the second argument is an array of 10 values. The show_master() function will returns the specified index value.
Assuming there is no error in main() complete the class Rectangle and its functions.
int main()
{
Rectangle rect1(3.4, 5.68);
Rectangle rect2(2.4, 4.68);
if (rect1-- != ++rect2) //increment/decrement will add & subtract by 1 of each data members of class
cout << ”\n Both are not of same size”;
else
cout << ”\n Both are of same size”;
rect1.show(); \\will display values 2.4, 4.68
Rectangle rect3 = rect1 + rect2;
rect3.show(); \\will display values 5.8, 10.36
system(“pause”);
return 0;
}
Assuming we have following variables and values:
int a=5, b=10, c=15, x, y, z;
Write the values of a, b and c variables in file by using formatted file I/O and then read data accordingly from file and assign it to x, y and z variables. Just create objects of relevant classes, there is no need to write entire main function.
let's we have a class named Distance having two private data members such as feet(integer),
inches(float), one input function to input values to the data members, one Display function to
show the distance. The distance 5 feet and 6.4 inches should be displayed as 5’- 6.4”. Then
add the two objects of Distance class and then display the result (the + operator should be
overloaded). You should also take care of inches if it's more than 12 then the inches should
be decremented by 12 and feet to be incremented by 1.
Assuming we have following variables and values:
int a=5, b=10, c=15, x, y, z;
Write the values of a, b and c variables in file by using formatted file I/O and then read data accordingly from file and assign it to x, y and z variables. Just create objects of relevant classes, there is no need to write entire main function.
Assuming there is no error in main() complete the class Rectangle and its functions.
int main()
{
Rectangle rect1(3.4, 5.68);
Rectangle rect2(2.4, 4.68);
if (rect1-- != ++rect2) //increment/decrement will add & subtract by 1 of each data members of class
cout << ”\n Both are not of same size”;
else
cout << ”\n Both are of same size”;
rect1.show(); \\will display values 2.4, 4.68
Rectangle rect3 = rect1 + rect2;
rect3.show(); \\will display values 5.8, 10.36
system(“pause”);
return 0;
}
a) Can we declare base class constructor or destructor as virtual if yes then why we want to do?
b) How we can declare a class as abstract and why we need abstract classes?
Why we cannot able to create objects of abstract classes give reasonable justification of that.
let's we have a class named Distance having two private data members such as feet(integer), inches(float), one input function to input values to the data members, one Display function to show the distance. The distance 5 feet and 6.4 inches should be displayed as 5’- 6.4”. Then add the two objects of Distance class and then display the result (the + operator should be overloaded). You should also take care of inches if it's more than 12 then the inches should be decremented by 12 and feet to be incremented by 1.
Assuming we have following variables and values:
int a=5, b=10, c=15, x, y, z;
Write the values of a, b and c variables in file by using formatted file I/O and then read data accordingly from file and assign it to x, y and z variables. Just create objects of relevant classes, there is no need to write entire main function.
Covid Vaccine registration booth:
1. frontline fighter
2. Citizen over 40 years
3. Student
Candidate info:
1.Name
2.Category
3.Registration no
4. Priority (age)
5. Age
Operation:
1. Registration
2. Show candidate list
3. Search candidate
using queue