Answer to Question #213003 in C++ for nadir

Question #213003

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-03T04:48:51-0400
#include <iostream>

using namespace std;

class String {
  string val;
  
  String(string val) {
    this->val = val;
  }
}

String * operator+ (const String &a, const String &b) {
  return new String(a.val + b.val);
}

int main() {}

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