Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > what's wrong with my codes?

Reply
Thread Tools

what's wrong with my codes?

 
 
lihewei126 lihewei126 is offline
Junior Member
Join Date: May 2007
Posts: 1
 
      05-21-2007
I use visual .net C++ to compile my source file,but I got some errors like

e:\project\test\test3\test3\Source1.cpp(6): error C2143: syntax error : missing ';' before '<'
e:\project\test\test3\test3\Source1.cpp(5): error C2143: syntax error : missing ';' before '<'
e:\project\test\test3\test3\Source1.cpp(5): error C2501: 'vector' : missing storage-class or type specifiers
e:\project\test\test3\test3\Source1.cpp(6): error C2501: 'vector' : missing storage-class or type specifiers
e:\project\test\test3\test3\Source1.cpp(6): error C2086: 'int vector' : redefinition
e:\project\test\test3\test3\Source1.cpp(6): error C2039: 'iterator' : is not a member of 'operator``global namespace'''
e:\project\test\test3\test3\Source1.cpp(10): error C2065: 'first' : undeclared identifier
e:\project\test\test3\test3\Source1.cpp(10): error C2065: 'v' : undeclared identifier
e:\project\test\test3\test3\Source1.cpp(10): error C2228: left of '.insert' must have class/struct/union type
type is ''unknown-type''
e:\project\test\test3\test3\Source1.cpp(10): error C3861: 'first': identifier not found, even with argument-dependent lookup
e:\project\test\test3\test3\Source1.cpp(13): error C2228: left of '.end' must have class/struct/union type
e:\project\test\test3\test3\Source1.cpp(13): error C3861: 'first': identifier not found, even with argument-dependent lookup
e:\project\test\test3\test3\Source1.cpp(13): error C3861: 'v': identifier not found, even with argument-dependent lookup
e:\project\test\test3\test3\Source1.cpp(13): fatal error C1903: unable to recover from previous error(s); stopping compilation





The following are my source codes:

#include <vector>
#include <list>
#include <deque>

vector<int> v;
vector<int>::iterator first = v.begin(),
last = v.end(); // cache end iterator
void main(void)
{
first = v.insert(first, 42);

// safer: recalculate end on each trip whenever the loop adds/erases elements
while (first != v.end()) {
// do some processing
first = v.insert(first, 42); // insert new value
++first; // advance first just past the element we added
}
}

What's wrong with my codes?
 

Last edited by lihewei126; 05-21-2007 at 04:23 AM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Have I bought wrong product? enquirer Wireless Networking 2 06-10-2005 10:59 PM
Zero Config keeps connecting to the wrong AP =?Utf-8?B?ZGdyaWZmaXRo?= Wireless Networking 2 03-04-2005 05:52 PM
Is XML Doc wrong or is Schema wrong? (or both) Matthew XML 7 01-07-2005 10:05 PM
wrong connection status Peter Welk Wireless Networking 0 12-22-2004 03:26 PM
XP SP2 Wrong IP on connection D Wells Wireless Networking 3 12-09-2004 03:35 AM



Advertisments