Cpp Program concatenation of string and compare two string with the help of operator overloding

Cpp programming  (pronounced see plus plus) is general-purpose programming language. Cpp programming is regarded as a "middle-level" language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language and originally named C with Classes. It was renamed Cpp programming in 1983.
As one of the most popular programming languages ever created, C++  programming is widely used in the software industry. Some of its application domains include systems software, application software, device drivers, embedded software, high-performance server and client applications, and entertainment software such as video games.  


cpp programs

 Here you will find cpp programs and cpp class example.This is just example you can modify this cpp class example.


cpp class example for how to do concatenation of string and compare two string with the help of operator overloding
/***************************
      author-Nikunj v Gandhi
      from-gujarat(surat)
      Web Developer(ZCE)
      email-nik_gandhi007@yahoo.com
      http://my-source-codes.blogspot.com/
      Description:CPP program- to concatenation of string and compare two string
      with the help of operator overloding in cpp operator == 
      for compare and + for concate

      ******************************************** */
      #include<conio.h>
     #include<iostream.h>
     #include<stdio.h>
     #include<string.h>
     const int size=50;
     class string
 {
   char str[size];
   public:
     string()
       {
  strcpy(str," ");
       }
     string(int n)
      {
       if(n==0)
    cout<<"nnBOTH THE STRING IS SAMEn";
       else
   cout<<"nnBOTH THE STRING IS NOT SAMEn";
      }
     string(char *mystr)
       {
  strcpy(str,mystr);
       }
     void input()
      {
       cout<<"Enter string?";
       gets(str);
      }
     string operator +(string s)
       {
  string temp=str;
  strcat(temp.str,s.str);
  return temp;
       }
     string operator ==(string s1)
       {
  int n;
  string temp1=str;
  n=strcmp(temp1.str,s1.str);
  return n;
       }
     void echo()
      {
       cout<<str;
      }
   };
   void main()
     {
       clrscr();
       string s1;
       cout<<"nstring 1n";
       s1.input();
       string s2;
       cout<<"nstring 2n";
       s2.input();
       string s3;
       s3=s1+s2;
       cout<<"AFTER CONCATE BOTH STRING IN 3rd STRING:";
       s3.echo();
       s1==s2;
       getch();
    }

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

1 comment:

It matters said...

Nice definition , have a look on my blog 2 plzCpp programs collection

Post a Comment