313304 OOP Practical on Write programs to define the function outside the class
The classes and objects help to represent real-life entities with different attributes and related Member functions.
Exercise:
1. Write syntax for define member function Outside the class.
Answer:
return_type class_name::function_name(parameter_list) {
// Function body
}
2. Write a C++ program to declare a class "staff' having data members name, basic salary, DA, HRA and calculate gross salary. Accept and display data for one staff.
Where DA=74.5% of basic
1. HRA= 30% of basic.
ii. Gross_salary=basic+HRA+DA
Answer:
Practical Related Questions
1. Write a program to find area of circle such that the class circle must have three functions
namely:
a)read() to accept the radius from user.
b)compute() for calculating the area
c)display() for displaying the result.(Use Scope resolution operator)
Answer:
2. Define a class complex with data members real and imaginary, member function read() and write(). Write a program to perform the addition of two complex number and display the result.
Answer:
3. Complete the following table:
Answer:
Conclusion
In this 313304 OOP practical no.5, we write various C++ codes to define the function outside the class and execute them successfully.