English
Tamil Nadu Board of Secondary EducationHSC Science Class 11

Answer the question based on the following program. What types of operands are used for the overloaded operator?

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; }

What types of operands are used for the overloaded operator?

One Line Answer
Advertisements

Solution

User-defined data type class (comp) objects are used.

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. (v) | Page 259
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×