So I was asked to write a C++ program to implement a string object. Include member functions to compare two strings, concatenate two strings and find out whether the strings are palindrome or not.
This is my Code.
#include <iostream>
#include<string.h>
using namespace std;
class STR
{
    public:
        void concatenateFunction(string s1, string s2);
        void compareFunction(string s1, string s2) ;
        void palindromeFunction(char str[]);
};
void STR::compareFunction(string s1, string s2)
{
    // comparing both using inbuilt function
    int x = s1.compare(s2);
    cout<< "Compare:\n";
    if (x != 0)
        cout << s1 << " is not equal to "
             << s2 << endl;
    if (x > 0)
        cout << s1 << " is greater than "
             << s2 << endl;
    else
        cout << s2 << " is greater than "
             << s1 << "\n" << endl;
}
void STR::concatenateFunction(string s1, string s2, char c)
{
    string conc = s1 + s2;
    cout << "Concatenate:\n" << conc << "\n";
    std::string str = conc;
    char* c = strcpy(new char[str.length() + 1], str.c_str());
    return;
}
void STR:: palindromeFunction(char str[])
{
    int l = 0;
    int h = strlen(str) - 1;
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            cout << str << " is Not Palindrome";
            return;
        }
    }
    cout << str << " is Palindrome";
}
int main()
{
    STR res;
    char c;
    string s1,s2,conc;
    cout << "Enter a string 1: ";
    getline(cin, s1);
    cout << "Enter a string 2: ";
    getline(cin, s2);
    res.compareFunction(s1, s2);
    res.concatenateFunction(s1, s2);
    return 0;
}
If you see in the concatenateFunction i'm trying to get the concatenate as a character so that i can perform the palindrome function. but as it is a std its showing error. So is their any workaround to make my code run. Please do help.
 
     
     
    