473,654 Members | 3,038 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(TurnStyleC ontextFSM *) {};
virtual void Pass(TurnStyleC ontextFSM *) {};
};

class LockedTurnStyle State : public TurnStyleState
{
public:
virtual void Coin(TurnStyleC ontextFSM* c)
{c->SetState(TurnS tyleContextFSM: :unLocked); c->Unlock();}

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

class UnlockedTurnSty leState : public TurnStyleState
{
public:
virtual void Coin(TurnStyleC ontextFSM* c)
{c->ThankYou();}

virtual void Pass(TurnStyleC ontextFSM* c)
{c->SetState(TurnS tyleContextFSM: :Locked); c->Lock();}
};

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

class TurnStyleContex tFSM : public TurnStyleContex t
{
private:
TurnStyleState* itsState;
public:
static UnlockedTurnSty leState Unlocked;
static LockedTurnStyle State Locked;
void Coin() {itsState.Coin( this);}
void Pass() {itsState.Pass( this);}

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

};

void main()
{
TurnStyleContex tFSM fsm;
fsm.SetState(Tu rnStyleContextF SM::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 'TurnStyleConte xtFSM'

Jul 22 '05 #1
4 1264
You have to forward declare TurnStyleContex tFSM.
Jul 22 '05 #2
Peter Gerell wrote:
You have to forward declare TurnStyleContex tFSM.


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******** *************** *******@localho st.talkaboutpro gramming.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(TurnStyleC ontextFSM *) {};
virtual void Pass(TurnStyleC ontextFSM *) {};
};

class LockedTurnStyle State : public TurnStyleState
{
public:
virtual void Coin(TurnStyleC ontextFSM* c)
At this point of compilation the class TurnStyleContex tFSM 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 'TurnStyleConte xtFSM'


HTH
Chris
Jul 22 '05 #4
"Peter Gerell" <ne***@gerell.s e> wrote in message news:<bv******* ***@yggdrasil.g localnet.com>.. .
You have to forward declare TurnStyleContex tFSM.


Even if you forward declared TurnStyleContex tFSM 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
2983
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 "import numarray" allows the exe to run. Left in, I get "4.exe has generated errors" etc. I'm going around and around and there isn't much on Google. py2exe output is last.
2
2067
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: Compiling /usr/local/lib/python2.3/xml/sax/saxutils.py ... Compiling /usr/local/lib/python2.3/xml/sax/xmlreader.py ... Compiling /usr/local/lib/python2.3/xmllib.py ...
3
2348
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 /usr/local/lib/python2.3/xml/sax/handler.py ... Compiling /usr/local/lib/python2.3/xml/sax/saxutils.py ... Compiling /usr/local/lib/python2.3/xml/sax/xmlreader.py ... Compiling /usr/local/lib/python2.3/xmllib.py ... Compiling /usr/local/lib/python2.3/xmlrpclib.py ......
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 ===================================================================== D:\\Scripts\B-4-2\la2luncher\dist>la2launcher.exe Traceback (most recent call last): File "la2launcher.py", line 9, in ? File "config.pyc", line 11, in ? File "config.pyc", line 8, in u LookupError: no codec search functions registered: can't find...
2
3071
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
1969
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
5354
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 the DLL. If I do a 'Batch Build' and select both Debug and Relase versions for building it will build the debug version but throws up errors for the Release version. For example, the output I get for a Batch Build is this - ...
13
9659
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
3554
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 ... Compiling /usr/local/lib/python2.5/xml/sax/__init__.py ... Compiling /usr/local/lib/python2.5/xml/sax/_exceptions.py ... Compiling /usr/local/lib/python2.5/xml/sax/expatreader.py ...
3
3439
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 got no reply, in an OpenGL group somebody recommended me to use Visual C++ which I did. That worked OK but I do would like to use Watcom. In the meantime I found solutions to several of the errors I got but one is left which I cannot find a...
0
8294
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1597
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.