#include <iostream>
#include <cstring>
using namespace std;
struct StringStructClass {
void initString(char *s); // public
void displayString();
private: // private
char str[255];
} ;
void StringStructClass::initString(char *s)
{
if(!*s)
*str = '\0'; // initialize string
else
strcat(str, s);
}
void StringStructClass::displayString()
{
cout << str << endl;
}
int main()
{
StringStructClass stringObject;
stringObject.initString("");
stringObject.initString("Hello ");
stringObject.initString("there!");
stringObject.displayString();
return 0;
}
|