when virtual member function of base class has no important task then it is advisable to overload this virtual member function by any derived class member function .
If we have to derive multiple classes from base class and these classes need methods of same type, then in this case take the base class as abstract and derive all the classes from it and implement the methods as desired in derived class.
Pure virtual functions in the base class doesn't have any body. The main advantage is that if a class has a pure virtual function, then its all derived classes must implement that function in them. One more advantage is that it tells the user that the object of that class cannot be created.
when we make a function virtual then it is forcing the derived class that it must have to be override and 2ndly this pure virtual fn dont allow to create any object of that class
Write a C++ program that contains a structure named ?Student? having two data members
1) Name
2) CGPA Declare array of structure ?Student? of size 10 .Populate this array by taking data from file inputFile.txt.File inputFile.txt contains Name and CGPA of the students for current semester. There is a single space between the Name and CGPA.
Display the un-sorted list of students on screen. Compare the CGPAs of all the students and sort Student List with respect to CGPA in ascending or descending order.
Display the sorted list of students, highest CGPA and lowest CGPA on screen and also write the result in File outputFile.txt with tab characters between the Name and CGPA. Sample InputFile.txt Ahmer 4.0
Aasim 3.5 Usman 3.4 Maria 2.4 Anila 3.0 Humza 2.6 Junaid 3.0 Talaal 3.8 Haris 3.9 Saira 2.6 Sample OutputFile.txt