Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


ASSIGNMENT # 6

FAISAL AHMED MEMON

MC080405059

 

 

#include<iostream.h>

#include<string.h>

#include<stdlib.h>

// class definition

class String

{

    private:

        char*buf;

        public:

            //constractors

            String();

            String(const char*s)

            {

                buf=new char[30];

                strcpy(buf,s);

            }

            // display  

            void display()

            {

                coutbufendl;

            }

            int length()const

            {

                return strlen(buf);

            }

            void operator=(const String &other);

        };

        void String::operator=(const String &other)

        {

            int length;

            length=other.length();

            delete buf;

            buf=new char [length+1];

            strcpy(buf,other.buf);

        }

        main()

        {

            String myString("=s2");

            cout"s1+";

            myString.display();

            cout"\n";

            String yourString("s3=");

            cout"\n";

            yourString=myString;

            cout"s3=s1+";

            yourString.display();

            cout"\n";

            system("pause");

        }   

                        

Views: 66

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service