English
Tamil Nadu Board of Secondary EducationHSC Science Class 11

Answer the question based on the following program. Write out the prototype of the overloaded member function.

Advertisements
Advertisements

Question

Answer the question based on the following program.

#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s[10];
void getstring(char str[10])
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
cout<<"\nStrings are Equal";
else
cout<<"\nStrings are not Equal"; }
int main()
{ comp ob, ob1;
char string1[10], string2[10];
cout<<"Enter First String:";
cin>>string1;
ob.getstring(string1);
cout<<"\nEnter Second String:";
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0; }

Write out the prototype of the overloaded member function.

One Line Answer
Advertisements

Solution

The prototype of the overloaded member function is as follows:
void comp::operator==(comp);

shaalaa.com
  Is there an error in this question or solution?
Chapter 15: Polymorphism - Evaluation - Section - D [Page 259]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 11 TN Board
Chapter 15 Polymorphism
Evaluation - Section - D | Q 4. (iv) | Page 259
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×