473,503 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in compiling the c++ code

#include <iostream.h>

/* This class captures all the events as virtual functions. This class
is a base class, and not one of the actual states of the FSM. */
class TurnStyleState
{
public:
virtual void Coin(TurnStyleContextFSM *) {};
virtual void Pass(TurnStyleContextFSM *) {};
};

class LockedTurnStyleState : public TurnStyleState
{
public:
virtual void Coin(TurnStyleContextFSM* c)
{c->SetState(TurnStyleContextFSM::unLocked); c->Unlock();}

virtual void Pass(TurnStyleContextFSM* c)
{c->Alarm();}
};

class UnlockedTurnStyleState : public TurnStyleState
{
public:
virtual void Coin(TurnStyleContextFSM* c)
{c->ThankYou();}

virtual void Pass(TurnStyleContextFSM* c)
{c->SetState(TurnStyleContextFSM::Locked); c->Lock();}
};

class TurnStyleContext
{
public:
void Lock();
void Unlock();
void Alarm();
void ThankYou();
};

class TurnStyleContextFSM : public TurnStyleContext
{
private:
TurnStyleState* itsState;
public:
static UnlockedTurnStyleState Unlocked;
static LockedTurnStyleState Locked;
void Coin() {itsState.Coin(this);}
void Pass() {itsState.Pass(this);}

TurnStyleState* GetState() {return itsState;}
void SetState(TurnStyleState* s) {itsState = s;}

};

void main()
{
TurnStyleContextFSM fsm;
fsm.SetState(TurnStyleContextFSM::Locked);
fsm.Lock();

for(;;)
{
fsm.Coin();
fsm.Pass;
}
}

I am compiling the above code in VC++ windows environment, i am getting the compilation errors like:
error C2061: syntax error : identifier 'TurnStyleContextFSM'

Jul 22 '05 #1
4 1255
You have to forward declare TurnStyleContextFSM.
Jul 22 '05 #2
Peter Gerell wrote:
You have to forward declare TurnStyleContextFSM.


And use a standard iostream header without the .h, because then comes the
string inclusion without the .h and the wondering while prestandard
iostreams and standard string does not owrk together. :-(

--
Attila aka WW
Jul 22 '05 #3

"ravinder" <ka***@mailcity.com> wrote in message
news:0c******************************@localhost.ta lkaboutprogramming.com...
#include <iostream.h>

/* This class captures all the events as virtual functions. This class
is a base class, and not one of the actual states of the FSM. */
class TurnStyleState
{
public:
virtual void Coin(TurnStyleContextFSM *) {};
virtual void Pass(TurnStyleContextFSM *) {};
};

class LockedTurnStyleState : public TurnStyleState
{
public:
virtual void Coin(TurnStyleContextFSM* c)
At this point of compilation the class TurnStyleContextFSM has not yet been
defined. However, you can resolve this problem by forward declaring it.

[SNIP]
I am compiling the above code in VC++ windows environment, i am getting the compilation errors like: error C2061: syntax error : identifier 'TurnStyleContextFSM'


HTH
Chris
Jul 22 '05 #4
"Peter Gerell" <ne***@gerell.se> wrote in message news:<bv**********@yggdrasil.glocalnet.com>...
You have to forward declare TurnStyleContextFSM.


Even if you forward declared TurnStyleContextFSM and made minor
corrections to the code (<iostream.h> to <iostream>, void main() to
int main(), Pass to Pass(),etc) it is still very unlikely that the
code will compile. Have you tried it?

Jai Kumar.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2971
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out...
2
2062
by: Chris Hadley | last post by:
I am installing Python 2.3.2 on AIX 4.3.3 I get to the point where I'm ready to "make install" and I get an error, with no idea how to get around it. Here's the tail end of the output: ...
3
2340
by: Zdenda | last post by:
Hi, i have RH9 and i need python 2.3. I executed tgz file and typed ./configue. Then i type make. It is without problem. When I type make install ... .... .... Compiling...
6
683
by: Club-B42 | last post by:
i've compiled my programm using command "python setup.py py2exe >1" python script works fine, but .exe version fails with =====================================================================...
2
3055
by: Gary | last post by:
Hi, I am a Chinese student, I have a problem with the following code //The follwing code in StaticSearch.h: // template <class Type> class dataList; // template <class Type> class Node ...
14
1939
by: Lee Franke | last post by:
I can't seem to figure this one out. Here is my class structure namespace name { public class foo { } }
5
5335
by: David++ | last post by:
Hi there, I have built a DLL in Visual C++ 6. When I build the DLL it builds fine for the debug version of the DLL (and this DLL works fine), however, I seem unable to build a Release version of...
13
9632
by: kamaraj80 | last post by:
Hi I am using the std:: map as following. typedef struct _SeatRowCols { long nSeatRow; unsigned char ucSeatLetter; }SeatRowCols; typedef struct _NetData
3
3548
by: Sebastian Bassi | last post by:
I was trying to install Python 2.5 compiling from sources. I used: ../compile It run OK. Then: make altintall After a lot of output, got this: Listing /usr/local/lib/python2.5/xml/sax ......
3
3427
by: Rene | last post by:
Hello to all! For a long time I have been "fighting" a problem compiling an OpenGL program which uses GLUT. First I have put a question in a Watcom group (I want to use this compiler) to which I...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.