Wednesday, July 17, 2019
Object-oriented Programming and Data Member
Lab Task Q1 Create a conformation that includes a data instalment that holds a serial flesh for for distributively one determination created from the yr. That is, the first object created get out be numbered 1, the second 2, and so on. To do this, youll need another data process that records a opine of how many objects strike been created so far. (This member should apply to the class as a whole not to individual objects. What keyword specifies this? ) Then, as each object is created, its constructor can examine this think member variable to determine the impound serial number for the new object.Add a member function that permits an object to advertise its own serial number. Then make unnecessary a main() program that creates three objects and queries each one about its serial number. They should act I am object number 2, and so on. Use copy constructor for this task some(prenominal) deep and modify copy. Q2 Create a class calculator. It would piddle two data memb ers, both whole number types. at that place would be four functions add(), sub(), mul() and div(). The mul() and div() functions would be relay transmitter functions. Create four objects of the class. in like manner use copy constructor both shallow and deep copy.There would be a static data member which would count the number of objects. Q3 Create a class GPACalculator. This class would have gpa, cgpa, sessionalMarks, midMarks and finalMarks data members. There would be two functions figureGPA() and calculateCGPA(). calculateCGPA() would be friend function. You need to create an represent of GPACalculator class. The array would be of 5. You also need to furnish the user option of whether he wants to calculate gpa or cgpa. The grades are as follows 50 and 53 and 57 and 61 and 64 and 68 and 72 and 75 and 80 and 86 and
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.