Answer to Question #213711 in C++ for shayan abbasi

Question #213711

Write a program having class STRING, With data member which can store character array (Dynamically you can store). It should facility to initialize by parameterize constructor and concatenate STRING objects.


Ex:  STRING obj1(“OOP”), obj2 (“IN KIIT”);


     Obj1 = obj1 + obj2;


Then obj1 should have “ OOP IN KIIT”  string in it. 


1
Expert's answer
2021-07-05T01:08:08-0400
#include <iostream>


using namespace std;
class STRING{
    private:
        string a; 
    public:
    
        STRING(string x){
            a=x;
        }
};
int main()
{
    STRING obj1("OOP"), obj2 ("IN KIIT");
    obj1 = obj1 + obj2;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS