Answer the question based on the following program. Mention the objects which will have the scope till the end of the program.
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; }
Mention the objects which will have the scope till the end of the program.
One Line Answer
Advertisements
Solution
Objects: ob and obi of main ()
shaalaa.com
Is there an error in this question or solution?
