Task#12 Assignment in C++
#include<iostream>
#include<cstring> //For CSTRING FUNCTIONS
using namespace std;
const int SZ=100;
class String
{
char Str[SZ];
public:
String() {strcpy(Str,""); } //INITIALIZATIION TO BLANKSPACES(DEFAULT CONSTRUCTER)
String(char s[]) {strcpy(Str,s); } //ASSIGN TO PRIVATE-DATA(1-ARGUMENT CONSTRUCTER)
void Display() //FOR DISPLAY CSTRING
{
cout<<"Concatenated String is: "<<Str;
}
String operator +(String S); //CONCATENTING OVERLOADING
};
String String::operator +(String S) //DEFINITION
{
return String(strcat(Str,S.Str));
}
int main()
{
String S1("\nJunaid Aslam ");
String S2="20SW084";
String S3;
S3=S1+S2;
S3.Display(); //DISPLAY CONCATENATED CSTRING..
}
Comments
Post a Comment