Search This Blog

Pages

Sunday, February 20, 2011

LabTask 4B.3

/*By Sailesh Dhoju*/

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

class concat
{
private:
int a,b;
char str[100];

public:
concat()
{
str[100]='\0';a=0;b=0;
}

concat(char *arr)
{
strcpy(str,arr);
}
void add(concat A,concat B)
{
a=strlen(A.str);
b=strlen(B.str);

for(int i=0;i<a;i++)
str[i]=A.str[i];
for(int j=a;j<(a+b);j++)
str[j]=B.str[j-a];
str[j]='\0';
}
void display()
{
cout<<str;
}
};

int main()
{
clrscr();
concat C;
concat A("This is just"),B(" an example.");
C.add(A,B);
C.display();
getch();
return (0);

}

No comments:

Post a Comment