CSC-121 (Last Assignment)
1. Create Matrix class. Provide default, 3-parameter (with rows and cols and 3rd
argument (with default value 0) to initialize all values of matrix with this value), and
another 3-parameter constructors with parameters rows, cols and a 2D array and
create the matrix object using a 2D array. Provide +, -, *, =, +=, -=, *=, [], (), << and
>> operators. Provide getters for rows and columns. Ensure there is no memory leak.
2. Create myString class. Implement constructors, destructor and all operators as
discussed in class. For reference read Chapter 12 from OOP text book by Tony Gaddis
et al. In addition, implement following functions of myString class from string library
class:
theString.append(str, p, n): Appends str to the theString. The argument str can be a
string object or a C-string. n number of characters from str, starting at position p, are
appended to theString. If the substring of str that begins at p has fewer than n
characters, only available characters are appended
theString.assign(str): Assigns str to theString. The parameter str can be a string object
or a C-string
theString.clear(): Clears the string by deleting all the characters stored in it.
theString.c_str(): Returns the C-string value of the string object
thString.swap(str): Swaps the contents of theString with str
3. Implement an inheritance hierarchy with abstract base class Person (with members:
cnic(string), name(string), email(string), contact no(string)), two derived classes
Student (with members: regno(string), semester, no of courses, a dynamic array of
courses and a dynamic array of marks obtained in courses) and Faculty (with
members: qualification(string), designation(string), area of expertise(string),
experience, and no of publications) and a class TA(with members: supervisor name,
thesis title, number of courses in which he is assisting in current semester along with
course info (dynamic array of courses), and total number of courses he has assisted
the teachers so far) derived from both Student and Faculty. There should be a course
class with course code, course title and no of credit hours to represent course
information of a course a student registers, with all constructors and getters and
setters. Write appropriate constructors, destructors and getters and setters for all
classes. Write functions to return an individual course’s gpa and semester cgpa in
student’s class. Write a bool function IsSuccessful() which returns either true or false.
Student is successful if his/her cgpa is 2.8 or higher. Teacher is successful if he has
either 10 or more years of experience or 5 or more publications. TA is successful if he
has 2.8 or higher cgpa and has assisted in 2 or more courses in total. Use virtual
inheritance, where required. Use virtual functions only when required. Write a main
function to test your classes. Declare array of pointers to Person and store different
derived class objects which are created dynamically in the array. Print the information
of persons in the array along with the info whether they are successful or not. Make
sure there is no memory leak.