hey ol,
i dnt hav much time left to solve des Q's.. can u plz guide me solving des...
Fundamental Exercise
/* class design, dynamic memory allocation and operator overloading */
1. Write a program to implement Matrix class.
• Implement addition and multiplication operation
• row and col of matrix is dynamic. So it should not be hard coded
• Implement copy constructor and copy assignment operator
• Implement post and pre increment / decrement operators to increment / decrement each elements in the matrix
• Overload the ostream << operator
• Private members will be as follows
o Int rows;
o Int cols
o Int **array;
/* class design, friends and operator overloading */
2. Write a program to implement your own string class
This class should have the following feature / function
a). size()
b). length()
c). resize()
d). append() - Append the string
e). insert() - Insert into string
f). erase() - Erase characters from the string
g). replace() - Replace part of the string
h). copy() - Copy sequence of characters from string
i). swap() - Swap contents with another string
j). find() - find content in string
k). rfind() - Find last occurrence of content in the string
Implement the following operators
a). [] - Get character at particular index
b). = Copy one string object to another
c). |= Append string
Implement the following global functions
a). operator+ (Concatenate two string into one)
b). operator<< (insert the string object into the output stream)
c). opeartor>> (extract a string from the input stream)
Template Assignment
1. Write a program for Generic linked list without using template and STL.
• Implement Add / delete functionality
• Find
2. Write a program for generic linked list with template and try to analyze both programs and understand the power of templates.
STL Exercise
1. Write a program to take input as a file. Read all the contents and then separates the file contents into list of words. Finally it should sort the list of words and print on the console and save it as a file.
2. Modify the above program to list all the words in a sorted order with number of occurrence in the file. The sorting can be based on word or number of occurrence. The option can be given using command line option.
Eg:
./a.out -n <inputfile>
-n is used for sorting based on number of occurrence
-w is used for sorting based on words
(if you want you can also add ascending or descending)
3. Write a program for index builder. Your program take ascii file as an input through command line argument. It reads all the contents and generate index for the words. It should print the index in a sorted order.
Example Output:
Word LineNo
===============
B
builder 10,22,25
business 15,30,150
I
Indent 11,33,44
index 2,10,20,100
industry 15,30
The output should be something similar to the above sample output. You need to have a class which handles all these operation and store the index in some kind of data structure. You need to identify the required data structure also to store the index.