Thursday, July 9, 2009

Write a program in C++ which creates two classes named as.....?

Write a program in C++ which creates two classes named as


• Marks


It should be a template class.


This class should contain following members


o Mid //for mid-term exam marks


o Final //for final-term exam marks


o Assignments //for assignments marks


All the three members should be of type template.


This class should also contain parameterized constructor that takes 3 parameters (marks of mid, final and assignments).


• Total


This class should be an ordinary class (should not be template class). It is meant to calculate the Total marks based on the sum of mid, final and assignments marks.


Contains following members


o Course //for course title


o Total_marks()


It should be a template function that takes a parameter of type marks. It adds the marks of mid, final and assignments and store the sum in its local variable named as result (should be of type template) and display it.





This class will also contain a parameterized constructor to initialize course data member.





In main , create two instances of template class Marks. One for int type and the other for float type members. Create two instances of Total class (for different course titles). Call the total marks of both the int and float type objects of the class Marks and display their result.





Note: You can use getter functions to access the members of one class from other.





Sample Output:





Total marks in OOP are 65





Total marks in DB are 66.5

Write a program in C++ which creates two classes named as.....?
Do your own flipping work! You want a degree for someone else doing your work????


No comments:

Post a Comment