0% found this document useful (0 votes)
29 views

Exp5 5

The document defines a product class with attributes like price, id, name. It has static methods to count objects created and display count. The main function creates an array of 5 product objects, accepts details using accept method, and displays details of each using display method. It shows object oriented concepts like classes, objects, methods, arrays.

Uploaded by

sakharam_gawade
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Exp5 5

The document defines a product class with attributes like price, id, name. It has static methods to count objects created and display count. The main function creates an array of 5 product objects, accepts details using accept method, and displays details of each using display method. It shows object oriented concepts like classes, objects, methods, arrays.

Uploaded by

sakharam_gawade
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

EXP5_5 #include<iostream.h> #include<conio.

h> class product { public: long int price; static int count; char *id,name[20]; static void cc() { count++; } static void cc1() { cout<<<"\nObjects created:\t"<count; } void accept() { product::cc(); cout<<"\nEnter Product name:\t"; cin>>name; cout<<"Enter the product price:\t"; cin>>price; } product(char *c="A0B0012") { id=c; } void display() { cout<<"\nProduct id:\t"<<id; cout<<"\nProduct name:\t"<<name; cout<<"\nProduct price:\t"<<price; } }; int product::count; void main() { int i; clrscr(); product p[5]; for(i=0;i<5;i++) { p[i].accept(); } product::cc1(); for(i=0;i<5;i++) { p[i].display(); } getch(); }

Page 1

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)

You might also like