'STRING' CLASS WHICH OVERLOAD '==' OPERATOR TO COMPARE TWO STRING OBJECT

hello friends....

TAKE THE FIRST STEP TO KNOWLEDGE FRIENDS BECAUSE KNOWLEDGE IS FREE.

/* CREATE A 'STRING' CLASS WHICH OVERLOAD '==' OPERATOR TO COMPARE TWO STRING OBJECT. */

#include<iostream.h>
#include<conio.h>
#include<string.h>
class string
{
  char str[20];
  public:
   void getdata()
   {
      //cut<<"\nEnter the string : ";
      cin>>str;
   }
   int operator==(string);
};
int string::operator==(string s)
{
  if(strcmp(str,s.str)==0)
  {
    return 1;
  }
  else
   return 0;
}

void main()
{
  clrscr();
  string s1,s2;
  cout<<"\nEnter the First String : ";
  s1.getdata();
  cout<<"\nEnter the Second String :";
  s2.getdata();

  if(s1==s2)
    cout<<"String is Equal!!!";
  else
    cout<<"String is NOT Equal!!!";
  getch();
}

   OUTPUT
=============

Enter the First String : dnp
Enter the Second String : developer
String is NOT Equal!!!

* * * * * * * * * * * * * *
>> IF YOU LIKE THIS BLOG, PLEASE SHARE AND SUBSCRIBE. ALSO COMMENT  FOR THIS BLOG.
>> IF YOU HAVE ANY QUESTIONS PLEASE ASK IN COMMENT.
>> IF YOU WANT TO LEARN HTML WITH OUTPUT, SO VISIT THIS BLOG
      https://dnpwebdeveloper.blogspot.com/
>> IF YOU WANT TO LEARN C++ PROGRAM WITH OUTPUT, SO VISIT THIS BLOG
      https://cplusplusdnpdeveloper.blogspot.com/
>> IF YOU WANT TO LEARN C PROGRAM WITH OUTPUT, SO VISIT THIS BLOG
      https://dnpdeveloper.blogspot.com/
>> MY INSTAGRAM ID : dnp176

Comments

Popular posts from this blog

RECEIVES TWO NUMBER AS AN ARGUMENT AND DISPLAY ALL PRIME NUMBER BETWEEN THESE TWO NUMBER

IMPLEMENT POWER FUNCTION USING FUNCTION OVERLOADING

SORT AN ARRAY OF INTEGER IN ASCENDING ORDER USING A FUNCTION BY REFERENCE