FUNCTIONS, CONSTRUCTOR, DESTRUCTOR & OVERLOADING QUESTIONS IN C++. (12)

Observe the following C++ code and answer the questions (i) and (ii).
Note Assume all necessary files are included in the program.

class Readbook
{
int Bcode;
char BName[25];
float Price;
public:
Readbook() //Funciton1
{
cout<<"Bought"<<endl;
Bcode=101;
strcpy(BName,"Computer");
Price=250;
}
Readbook(int C,char N[],float P) //Funciton2
{
Bcode=C;
strcpy(BName, N);
Price=P;
}
void Rate(float P)
{
Price += P;
}
void Output() //Function3
{
cout<,Bcode<<":"<<BName<<":"<<Price<<endl;
}
 Readbook() //Funciton4
{
cout<<"Book Finished."endl;
}
};
void main() //Line1
{ //Line2
Readbook R1,R2(112,"Information",425); //Line3
for(int i=0;iM<5;i++) //Line4
{ //Line5
R1.Rate(320); //Line6
R2.Output(); //Line7
R2.Rate(225); //Line8
R1.Output(); //Line9
} //Line10
} //Line11

(i) How many times the message "Book Finished." will be displayed after executing the above C++ code? Out Line1 to Line11, which line is responsible to display the message "Book Finished."?

(ii) Which specific concept of Object Oriented Programming out of the following is illustrated by Funciton1 and Funciton2 combined together?



No comments

Post your comments

Powered by Blogger.