473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

expected `;' before "it"

Hello,

In a template implementation, I am trying to define a list iterator using the following line:

list<AI>::const_iterator it;

However, I get the following error:

expected `;' before "it"

I have included #include <list>
and using namespace std at the beginning of my code. But the problem did not go away. I would apprecate any insight. Thanks.
Jul 4 '07 #1
8 2822
weaknessforcats
9,208 Expert Mod 8TB
You forgot to #include <list>.
Jul 4 '07 #2
no, I have #include<list>
but I still get this error.
Jul 4 '07 #3
Are you using:

Expand|Select|Wrap|Line Numbers
  1. using namespace std;
If not try the following in your declaration.

Expand|Select|Wrap|Line Numbers
  1. std::list
Jul 5 '07 #4
Sorry for not writing it clearly but as can be seen from my inital post, I have

#include<list>
using namespace std;

at the beginning of my code. But to no avail, I am still getting the error.
Jul 5 '07 #5
Meetee
931 Expert Mod 512MB
Hello,

In a template implementation, I am trying to define a list iterator using the following line:

list<AI>::const_iterator it;

However, I get the following error:

expected `;' before "it"

I have included #include <list>
and using namespace std at the beginning of my code. But the problem did not go away. I would apprecate any insight. Thanks.
Try this:

typedef typename list<AI>::const_iterator observerIterator;
observerIterator it;

OR

typename list<AI>::const_iterator it;

It may help..!

Regards
Jul 5 '07 #6
weaknessforcats
9,208 Expert Mod 8TB
This compiles and links with Visual Studio.NET 2005
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3. #include <list>
  4. class AI
  5. {
  6.  
  7. };
  8. int main()
  9. {
  10.     list<AI>::const_iterator it;
  11. }
  12.  
Jul 5 '07 #7
Thanks,

typename list<AI>::const_iterator it;

did the trick.

I am still not familiar with the subtleties of these but weaknessforcats, somehow your post#7 seems to me a different thing. Because in your example you already declare and define a class AI. So computer has no problem, recognizinf list<AI>. Whereas when AI is going to be determined when a template is initiated we are having additional problems when we write list<AI>.
Jul 5 '07 #8
weaknessforcats
9,208 Expert Mod 8TB
I am still not familiar with the subtleties of these but weaknessforcats, somehow your post#7 seems to me a different thing. Because in your example you already declare and define a class AI. So computer has no problem, recognizinf list<AI>. Whereas when AI is going to be determined when a template is initiated we are having additional problems when we write list<AI>.
The originakl problem was that:
list<AI>::const_iterator it;
was not compiling.

This looks like you want to create an const iterator object, it, for a list<AI>. You know, so you can:
Expand|Select|Wrap|Line Numbers
  1. list<AI> mylist;
  2. list<AI>::const_iterator it = mylist.begin();
  3.  
That is what my post #7 was about.

This:
Expand|Select|Wrap|Line Numbers
  1. typename list<AI>::const_iterator it;
  2.  
only works if it is inside a template. You can't use typename outside a template. The original problem said nothing about the code being inside a template.
Jul 6 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: R. Westermeyer | last post by:
Hi, I moved my domain (habitsmart.com) to earthlink, and the self-scoring form doesn't work anymore. Anyone know of an outfit that does quick cgi/perl fix it at a reasonable price? Thanks. ...
0
by: chris yoker via DotNetMonster.com | last post by:
hiya, I previously obtained code that enabled me the replace a node and its innerText.The code relied on the node that was to be replaced having ?childNodes? However, it seems that the nodes...
5
by: Stan | last post by:
When I create a Web project and then try to add the files to it (Add Existing Item), I get this error message "The folder http://localhost/FinWeb is no longer availabe" In fact the folder and...
1
by: Patrick Blackman | last post by:
I am getting this message above when I try to place any custom component or usercontrol on a form. In previous version when I created a usercontrol I could drag it from the toolbox and place it on...
7
by: Chris | last post by:
Hello all... I have a program with the following structure (all classes mentioned are of my own creation, and none of the classes contain try or catch blocks): - main() consists of a large...
2
by: Matt Brown - identify | last post by:
Hello, I decided to not spend the rest of my life figuring out docking and, instead, use the cDockingHandler class offered on Veign.com (http:// www.veign.com/vrc_codeview.asp?type=app&id=149)....
2
ramprabu
by: ramprabu | last post by:
Hello, I will give the sample code of html. Here first table only apply border 1 width. other tables are border 0. The problem is border=0 means border was not visible but it takes white border...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
1
FLEB
by: FLEB | last post by:
Something in my gut tells me this is an FAQ, but my furious Googling thus-far hasn't found the answer (Biggest problem? The terms I'm looking for are in the license itself. Search, and... get... 50...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.