InterviewSolution
 Saved Bookmarks
    				| 1. | 
                                    Answer the questions based on the following program #include #include using namespace std; class comp {public:char[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”;elsecout<< “\nStrings are not Equal”;}int main(){comp ob, ob1;char stringl[10], string2[10];cout <<“Enter First String:”; cin>> string1; ob.getstring(string1);cout<<“\n Enter Second String:”; cin>> string2; ob1.getstring(string2);ob = = obi;return 0;}(i) Mention the objects which will have the scope till the end of the program.(ii) Name the object which gets destroyed in between the program.(iii) Name the operator which is over loaded and write the statement that invokes it.(iv) Write out the prototype of the overloaded member function.(v) What types of operands are used for the overloaded operator?(vi) Which constructor will get executed? Write the output of the program | 
                            
| 
                                   
Answer»  (i) Objects: ob and obi of main () (ii) object ob of void operator = = (comp ob); (iii) Overloaded operator: = = Statement that invokes: ob = = ob1; (v) void operator = = (comp ob): (v) Operands used are the objects of the class comp (vi) The default constructor generated by the compiler will be executed.[comp();] Output 1 Enter first string: hello Enter second string: hello String are equal Output 2 Enter first string: hello Enter second string: fine String are not equal  | 
                            |