CLASSES

Hello everybody ,, i am in need of your help on hw to convert a function to classes,,thank you ..
<code>
source:




void Delete(struct Queue *My)
{
if(My->st[0]==My->st[1])
{
printf("

U SUCK:- Nothing To Delete:-");
getch();
return;
}
My->st[0]=My->st[0]+1;
printf("
One Element Deleted . . .");
}

void DISPLAY(struct Queue My)
{
int g=DETECT,d,i;
int j=400;
char str[10];

if(My.st[0]>=My.st[1])
{
printf("

Hey Wicked, Atleast PUSH One Item");
getch();
return;
}

initgraph(&g,&d,"c:\tc\bgi");

setbkcolor(BLUE);
outtextxy(10,10," Press Any Key...");
getch();

setfillstyle(11,12);
for(i=2;i<20;i++)
{
setcolor(RED);
bar(200,j,400,j-20);
rectangle(200,j,400,j-20);
j=j-20;
}
j=400;
for(i=2;i<My.st[0];i++)
{
setcolor(RED);
rectangle(200,j,400,j-20);
j=j-20;
}
setfillstyle(1,CYAN);
for (i=My.st[0];i<My.st[1];i++)
{
setcolor(GREEN);
delay(200);
bar(200,j,400,j-20);
rectangle(200,j,400,j-20);
sprintf(str,"%d",My.st[i]);
setcolor(RED);
outtextxy(280,j-10,str);
j=j-20;
}
j=390;
for(i=2;i<My.st[0];i++)
j=j-20;
outtextxy(410,j," <- Rear Pointer");

j=390;
for(i=2;i<My.st[1];i++)
j=j-20;
outtextxy(410,j," <- Front Pointer");

getch();
restorecrtmode();
}

</code>
1. Please use code tags properly. See http://cplusplus.com/articles/z13hAqkS/ for details.
2. A function can be added to a class quite easily. You just need to design your classes first in a way things makes sense.
3. Read this: http://www.cplusplus.com/doc/tutorial/classes/
Topic archived. No new replies allowed.