why code is not working properly

N

nik

hello friends , iam working on finite state machine .i have some
problem regarding code that i have executed in borland compiler
..following

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
static int a,b,c;//d,e,f;
class rectan
{
public:
virtual void rectam()
{
}
virtual void getdata()
{
}
virtual void recta(int x1,int y1,int x2,int y2,int bc)
{
setcolor(bc);
rectangle(x1,y1,x2,y2);
}
};
class lin
{
public:
void line_(int x1,int y1,int x2,int y2, int bc)
{
setcolor(bc);
line(x1,y1,x2,y2);
}
};
class smach:public rectan,public lin
{
public:
void rectam()
{
outtextxy(235,0,"FINITE STATE MACHINE");
rectan::recta(0,10,a,b,2);
outtextxy(a/2-18,20,"STATE");
outtextxy(a/2-27,32,"MACHINE");
rectan::recta(a/2-30,15,a/2+30,45,5);
}
};
class state:public rectan,public lin
{
protected:
int s,j;
public:
void getdata()
{
cout<<"Enter the no of states max 5= "<<endl;
cin>>s;
c=s;
}
void rectam()

{
j=0 ;
while(j<c)
{
rectan::recta(((a/c)((1/2)+j)-20),140,((a/c)((1/2)+j)+20),180,8);
j++;
}
}
};
class event: public state
{
int u[10],i;
public:
void getdata()
{
cout<<"enter no of event in each state max 5 = "<<endl;
i=0;
while(i<c)
{
cin>>u;
i++;
}
};
void main()
{
int gd=DETECT,gm;
rectan *ptr;
rectan r;
state t;
ptr=&t;
ptr->getdata();
event e;
ptr=&e;
ptr->getdata();
initgraph(&gd,&gm,"c:\\bc5\\bgi");
a=getmaxx();
b=getmaxy();
ptr=&t;
ptr->rectam();
smach y;
ptr=&y;
ptr->rectam();
getch();
closegraph();
restorecrtmode();
}
and flowing r the eror occur in it
Info :Compiling C:\amit\fsmgra2.cpp
Warn : fsmgra2.cpp(57,1):Functions containing while are not expanded
inline
Error: fsmgra2.cpp(59,3):Call of nonfunction
Error: fsmgra2.cpp(59,3):Call of nonfunction
Warn : fsmgra2.cpp(72,1):Functions containing while are not expanded
inline
Error: fsmgra2.cpp(101,1):Declaration terminated incorrectly
 
D

Daniel T.

"nik said:
hello friends , iam working on finite state machine .i have some
problem regarding code that i have executed in borland compiler
.following

and flowing r the eror occur in it
Info :Compiling C:\amit\fsmgra2.cpp
Error: fsmgra2.cpp(59,3):Call of nonfunction
Error: fsmgra2.cpp(59,3):Call of nonfunction

My compiler says:
error: '(a / c)' cannot be used as a function

The compiler thinks you are trying to call the function (a/c) with the
argument ((1/2)+j).

See if you can't remove some of those parens.
 
S

shadowman615

Daniel said:
My compiler says:
error: '(a / c)' cannot be used as a function

The compiler thinks you are trying to call the function (a/c) with the
argument ((1/2)+j).

See if you can't remove some of those parens.

Not so much the parens -- perhaps you meant ((a/c)*((1/2)+j)-20)

??
 
V

Victor Bazarov

Daniel T. said:
My compiler says:
error: '(a / c)' cannot be used as a function

The compiler thinks you are trying to call the function (a/c) with the
argument ((1/2)+j).

See if you can't remove some of those parens.

Could it be multiplication operators are missing there somewhere?

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top