Warning: include_once(../../../headder.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/computer_science/chapter5_b.php on line 16

Warning: include_once(): Failed opening '../../../headder.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/computer_science/chapter5_b.php on line 16

CBSE eBooks

CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK

Chapter – 5. CONSTRUCTORS & DESTRUCTORS

Previous Index Next


Warning: include(../../../ads_330x250_middle.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/computer_science/chapter5_b.php on line 26

Warning: include(): Failed opening '../../../ads_330x250_middle.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/computer_science/chapter5_b.php on line 26

OUTSIDE DELHI 2008

2.b. Answer the questions (i) and (ii) after going through the following program:

#include<iostream.h>
#include<string.h>
class Retail
{
char category[20];
char item[20];
int qty; float price;
retail () //function 1
{
strcpy (category, “cerial”);
strcpy (Item, “Rice”); qty =100 ;
price =25 ;
}
public; void show() //function 2
{
cout << category <<”-“<< Item << “:”<<Qty<<“@”<< price<<endl;
}
};
void main()
{
Retail R; //statement 1 R.
show (); //statement 2
}

(i) will statement 1 initialize all the data members for objects R with the given in the function 1 ? (YES OR NO). Justify your Answer suggesting the corrections(s) to be made in the above code.

Ans: No. The reason is the constructor should be defined under the public visibility label.

(ii) What shall be the possible out put when the program gets executed ? (Assuming, if required the suggested correction(s) are made in the program)

Ans: Possible Output: cerial–Rice:100@25

2.c. Define a class clothing in c++ with the following descriptions :

private members :

code of type string
type of type string
size of type intiger
material of type string
price of type float

A function calc_price( ) which calculates and assigns the value of GPrice as follows ;

For the value of material as “COTTON” :

Type price (Rs)
TROUSER 1500
SHIRT 1200

for material other than “COTTON”, the above mentioned GPprice price gets reduced by 25%

Previous Index Next


Warning: include(../../../120_60_others.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/computer_science/chapter5_b.php on line 101

Warning: include(): Failed opening '../../../120_60_others.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/computer_science/chapter5_b.php on line 101