Wednesday, 18 May 2016

Write a program to implement following main() function: int main() { string str1(“MCKVIE”),str2(“MCKVIE”); if(str1= =str3) cout<<”A”; else cout<<”B”; return 0; }

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

 class string{
public:
char str[100];
string(char *);
int operator==(const string& s){
if(! strcmp(this->str,s.str))
return 1;
      else
return 0;

}



};

string::string(char *s){
strcpy(str,s);
}

void main()
{

    string str1("MCKVIE"),str2("MCKVIE");

    clrscr();
    if(str1==str2)
    cout<<"A";
    else
    cout<<"B";
    getch();
}

No comments:

Post a Comment