### Pointers question..pls help(answer givn)...cant understand the foll question

Q>Design a class BIGBAZAR to store order information. Each order information has an 11-character item code, 20- character item name, price and an integer quantity. Provide the following member functions in a class:-
1. member functions to read these records from standard input getdata(),
2. to calculate the total price calculate(){private member function)
3. sort functions to arrange data by ItemCode sort(),
4. to dispay the same and display the totalprice display().
Also use static variable count and static member function displaycount() to display the number of records.
Example:
ItemCode ItemName Quantity Price totalprice Units
BIGBAZZAR5 Sugar 1 40 40 Kg
BIGBAZZAR2 Potato 2 60 120 Kg
BIGBAZZAR1 Milk 1 30 30 Liter
BIGBAZZAR4 BOWL 5 130 650 _
BIGBAZZAR3 BUCKET 1 80 80 _

#include<conio.h>
#include<iostream.h>
class BIGBAZAR
{
int t_price;
int qty;
int price;
char item_code[11];
char item_name[20];
char units[6];
static int count;
void calculate()
{

t_price=qty*price;
}
public:
void getdata();
friend void sort(BIGBAZAR *b);
void display();
static void displaycount();
};
int BIGBAZAR ::count;
void BIGBAZAR ::getdata()
{
cout<<"\nEnter the ITEM code\t\t";
cin>>item_code;
fflush(stdin);
cout<<"\nEnter the ITEM name\t\t";
cin>>item_name;
fflush(stdin);
cout<<"\nEnter the qty\t\t\t";
cin>>qty;
fflush(stdin);
cout<<"\nEnter the price\t\t\t";
cin>>price;
fflush(stdin);
cout<<"\nenter the units\t\t\t";
cin>>units;
fflush(stdin);
count++;
}
void sort(BIGBAZAR p[])
{
BIGBAZAR temp;
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5-1-i;j++)
{
if(p[j].item_code[9]>p[j+1].item_code[9])
{
temp=p[j];
p[j] =p[j+1];
p[j+1]=temp;
}
}
}
}

void BIGBAZAR ::display()
{
calculate();
cout<<item_code<<"\t"<<item_name<<"\t\t"<<qty<<"\t\t"<<price<<"\t\t"<<t_price<<"\t"<<units<<endl;
}
void BIGBAZAR ::displaycount()
{
cout<<"\n\nThe number of records are:\t\t"<<count;
}
void main()
{
clrscr();
BIGBAZAR p[5];
int i;
for(i=0;i<5;i++)
{
p[i].getdata();
}
cout<<"ITEM CODE\tITEM NAME\tquantity\tprice\ttotalprice\tunits\n";

for(i=0;i<5;i++)
{
p[i].display();
}
sort(&p[0]);
cout<<"\nsorted list is:\n";
cout<<"ITEM CODE\tITEM NAME\tquantity\tprice\ttotalprice\tunits\n";

for(i=0;i<5;i++)
{
p[i].display();
}
BIGBAZAR::displaycount();
getch();
}

My doubts: Basically, i cant understan the use of pointer here? why are we using pointers and when it is defined p[] is used...i dont understand how it is written ...cant p[0] or &p be used...and when it is called &p[0] is used....I am not able to understand anyting... :(((( .... plssss help
http://www.cplusplus.com/doc/tutorial/pointers/

Your question is kind of vague...can you quote specific code?
Thank you for the link,Sir

My question is that in this program i cant understand the function sort.
In this program various items are being entered by the user and displayed after sorting the item code. The itemcode is in the form BIGBAZAR4( BIGBAZAR and then the no.)(bigbazar is a name of indian retail shop). so i am sorting the 9th element in the array...but i cant uderstand how the programme is being declared,defined and called...

Thanks
Topic archived. No new replies allowed.