codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  What`s the reason for these errors in c++ STL  vivekc++ at 14:36 on Wednesday, February 11, 2009
 

#include<iostream>
#include<list>

using namespace std;

int main()
{
list<int> dob;

for(int i=0;i<5;i++)
{
dob.push_back(i);
}


for(int i=0,list<int>::iterator itr=dob.begin();i<3;itr++,i++)
cout<<*itr;

return 0;
}


errors--

test.cpp: In function `int main ()':
test.cpp:17: `iterator' specified as declarator-id
test.cpp:17: extraneous `int' ignored
test.cpp:17: `int list<int, allocator<int> >::iterator' is not a static
member of `class list<int, allocator<int> >'
test.cpp:17: parse error before `='
test.cpp:17: `itr' undeclared (first use this function)
test.cpp:17: (Each undeclared identifier is reported only once for each
function it appears in.)



  Re: What`s the reason for these errors in c++ STL  jinhao at 07:50 on Wednesday, April 22, 2009
 

you can't define two objects of different types in a single statement.

list<int>::iterator itr=dob.begin();
for(int i=0;i<3;itr++,i++)
cout<<*itr;








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
• C++
• Re: refresh parent after closing pop up window
• Dynamic Insertion
• Date and Time function around the world???
• Significant Factors
• Perl array access
• Re: huffman encoding and decoding in C++...
• Perl One Liner: Replace {(
• Re: html including php, accessing the functions


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009