Chapter – 5. CONSTRUCTORS & DESTRUCTORS

public members :

* A constructor to assign initial values of code ,type and material with the word “NOT ASSIGNED “and size and price with 0.

* A function enter() to input the values of the data members code, type, size and material and invoke the caclPrice () function.

* A function show which displays the content of all the data members for a clothing.

#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
class clothing
char Code[21],Type[21];
{
int size;
char material[21];
float price;
void calc_price( )
{
if(strcmp(strupr(material),"COTTON")==0)
{
if(strcmp(strupr(Type),"TROUSER")==0) price=1500;
if(strcmp(strupr(Type),"SHIRT")==0) price=1200;
}
else
{
if(strcmp(strupr(Type),"TROUSER")==0) price=1500*0.75;
if(strcmp(strupr(Type),"SHIRT")==0) price=1200*0.75;
}
}
public: clothing( )
strcpy(Code,"NOT ALLOTED");
{
strcpy(Type,"NOT ALLOTED"); size=0;
strcpy(material,"NOT ALLOTED"); price=0;
}
void enter( )
cout<<"\nEnter the Cloth Code: ";
{ gets(Code);
cout<<"\nEnter the Cloth Type: ";
gets(Type);
cout<<"\nEnter the Cloth Size: ";
cin>>size;
cout<<"\nEnter the cloth material: ";
gets(material); calc_price( );
}
void show( )
{
cout<<"\nThe Cloth Code: "<<Code;
cout<<"\nThe Cloth Type: "<<Type;
cout<<"\nThe Cloth Size: "<<size;
cout<<"\nThe Cloth Material: "<<material;
cout<<"\nThe Cloth Price: "<<price;
}
};
void main( )
{
clothing C;
C.enter( );
C.show( );
}


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter5_c.php on line 138

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter5_c.php on line 138

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter5_c.php on line 140

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter5_c.php on line 140