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.

The forum announcement here suggests that no one here would be willing to provide you homework help unless you show some effort. But I ain't much of an obeyer of the rules myself....sssssshhh.... *talking in a low voice* I can help you solve these assignments, even if you don't show any effort, provided you help me buy a Ferrari.

its not homework... i solved but its not efficient, i need some ideA to get started, i did many functns of second program too. plz plz i cant get u ferrari, but i can pray dat u get ferrari...

its not homework... i solved but its not efficient, i need some ideA to get started, i did many functns of second program too. plz plz i cant get u ferrari, but i can pray dat u get ferrari...

Then I too cannot help you do your assignments, but believe me I will offer more than the traditional rituals in prayer to request GOD to help you get your assignments done. ;)

Okay on a more serious note, put out the code here, whatever you've written, specify the problems or where you get stuck and I am sure people will help you here, even if they don't actually get a ferrari.

tasneemnikhat. Please use complete English words when you post.
Why do you need to complete the excercise quickly?

Then I too cannot help you do your assignments, but believe me I will offer more than the traditional rituals in prayer to request GOD to help you get your assignments done. ;)

Okay on a more serious note, put out the code here, whatever you've written, specify the problems or where you get stuck and I am sure people will help you here, even if they don't actually get a ferrari.

ok ill submit ma code.. hope den u ol vl guide me.. m new to dis si8 so donno mch rules n ol

ok i will not use any shortcuts. my exams are nearing before that i need to solve these, so that i can concentrate n study.
i know the logic but iam facing problem in writing the syntax

#include<iostream>
#include<stdlib.h>
#include<iomanip>
//#include"matrixd.h"
using namespace std;
class matrixd
{
        public:
        matrixd();
        matrixd(int r, int c);

        matrixd(const matrixd &);
        matrixd operator + (const matrixd&);

        matrixd& operator = (const matrixd&);
        matrixd operator ++ (int);
        matrixd operator ++ ();
        friend ostream & operator<< (ostream &,const matrixd &);
        ~matrixd();

        private:
        int ROW;
        int COL;
        int **data;
};

//DEFAULT CONSTRUCTOR
matrixd::matrixd():ROW(0),COL(0)
{
}
matrixd::matrixd(int r, int c)
{
        ROW = r;
        COL =c;
        data = new int*[r];


        for(int i =0;i<r;i++)
                {
                        data[i]=new int[c];
                }

        for(int i=0;i<r;i++)
                {
                        for(int j=0; j<c; j++)
                                {

                                        data[i][j]=0;

                                }

                }
}

matrixd matrixd::operator+(const matrixd & operand)
        {
                matrixd temp(ROW,COL);

                for(int i=0;i<ROW;i++)
                        {
                                for(int j=0;j<COL;j++)
                                        {
                                                temp.data[i][j]=data[i][j]+operand.data[i][j];
                                        }
                        }
                return temp;
        }

 matrixd& matrixd :: operator=(const matrixd & operand)
        {


                if(this!=&operand)
                        {

                                for(int i=0;i<operand.ROW;i++)
                                        {
                                                for(int j=0;j<operand.COL;j++)
                                                        {
                                                                data[i][j]=operand.data[i][j];
                                                        }
                                        }
                        }
                return *this;
        }

ostream & operator<<(ostream & out, const matrixd& operand)

{
                for(int i=0;i<operand.ROW;i++)
                        {
                                for(int j=0;j<operand.COL;j++)
                                        {
                                                out<<operand.data[i][j]<<" ";
                                        }
                                out<<endl;
                        }
                return out;
}
matrixd::matrixd(const matrixd & operand)
        {
                                for(int i=0;i<ROW;i++)
                                delete [] data[i];
                                delete [] data;

                                data=new int *[operand.ROW];
                                for(int i=0;i<operand.ROW;i++)
                                        {
                                                data[i]=new int[operand.COL];
                                        }
                                ROW=operand.ROW;
                                COL=operand.COL;
                                for(int i=0;i<operand.ROW;i++)
                                        {
                                                for(int j=0;j<operand.COL;j++)
                                                        {
                                                                data[i][j]=operand.data[i][j];
                                                        }
                                        }
        }
//destuctor
matrixd::~matrixd()
{
        for (int i=0;i<ROW;i++)
        delete [] data[i];
        delete [] data;
}

typedef matrixd Matrix;

int main()   {

Matrix o1(2,5);
Matrix o2;
cout << o1 << o2 ;

o2 = o1++;
o1++;
cout << o1 << o2;

o2 = o1++;
cout << o1 << o2;

Matrix o3(o1 + o2);
cout << o1 << o2 << o3 ;

Matrix o4;
o4 = o1 + o3;
cout << o1 << o2 << o3;

o1 = o2 = o3 = o4 ;
cout << o1 << o2 << o3 << o4 ;
Matrix &o5 = o1;
o5++;
cout << o1 << o5;
return 0;
}

i am not getting any compilation errors, but i am getting linker errors like undefined reference to operator and all...how to resolve this??

i have included ol the test cases in main. i doubt about the copy constructor.please help me know if there is any problem with ma code

This question has already been answered. Start a new discussion instead.