Following is the code for string builder:
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
class stringbuilder{
private:
vector<string> words;
vector<char> complete_string;
string concatenate_string()
public:
void insert_words(string s);
string get_string();
};
void stringbuilder::insert_words(string s){
words.push_back(s);
}
string stringbuilder::get_string(){
string ret;
for(string x:words){
ret += x;
}
return ret;
}
int main()
{
stringbuilder sb;
string str[] = {"Yalmuri ", "Sreenivasulu ", "Reddy."};
for(string x : str)
sb.insert_words(x);
cout<<sb.get_string()<<endl;
return 0;
}
Comments
Post a Comment