IGNOU, SMU and KSOU Bsc solved assignments – C++ program is for Operator Overloading, Concatenating 2 strings

IGNOU, SMU and KSOU Bsc solved assignments – C++ program is for Operator Overloading. Concatenating 2 strings

If you are BSc IT, Btech C/S, Msc computer science or Bsc computer science students and looking for solved assignments on C++ here is proper solution.

Below C++ program is for   Operator Overloading. Concatenating 2 strings. It is solved assignment for IGNOU, SMU and KSOU Bsc IT or Computer science students.

// Operator Overloading.
// Concatinuating 2 strings.

#include<iostream.h>
#include<conio.h>
#include<string.h>

class String
{
private : char s[100];

public :
String();
String(char str[]);
void putstr();
String operator+(String);
};

String :: String(){}

String :: String(char str[])
{
strcpy(s,str);
}

void String :: putstr()
{
cout<<s;
}

String String :: operator+(String s2)
{
String temp;
strcpy(temp.s,s);
strcat(temp.s,s2.s);
return(temp);
}

void main()
{
clrscr();

String s1=” WELCOME “;
String s2=” To C++ Programs. “;
String s3;

cout<<”\n First String is : “;
s1.putstr();

cout<<”\n Second String is : “;
s2.putstr();

s3=s1+s2;

cout<<”\n Concatinuation of the string is : “;
s3.putstr();

getch();
}

All New Updates

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code: