Error in a vector program
I'm trying to run this simple program in "Visual C++ 2008 Express Edition":
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
#include <vector>
#include "stdafx.h"
int main(){
std::vector<bool> features(4,false);
for(std::vector<bool>::iterator i = features.begin(); i != features.end(); i++){
std::cout<<features[i];
}
}
|
When I do that, I get the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
1
|
1>Compiling...
1>SFS.cpp
1>.\SFS.cpp(1) : warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>.\SFS.cpp(2) : warning C4627: '#include <vector>': skipped when looking for precompiled header use
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>.\SFS.cpp(6) : error C2653: 'std' : is not a class or namespace name
1>.\SFS.cpp(6) : error C2065: 'vector' : undeclared identifier
1>.\SFS.cpp(6) : error C2062: type 'bool' unexpected
1>.\SFS.cpp(7) : error C2653: 'std' : is not a class or namespace name
1>.\SFS.cpp(7) : error C2065: 'vector' : undeclared identifier
1>.\SFS.cpp(7) : error C2062: type 'bool' unexpected
1>.\SFS.cpp(7) : error C2039: 'iterator' : is not a member of '`global namespace''
1>.\SFS.cpp(7) : error C2065: 'i' : undeclared identifier
1>.\SFS.cpp(7) : error C2065: 'features' : undeclared identifier
1>.\SFS.cpp(7) : error C2228: left of '.end' must have class/struct/union
1> type is ''unknown-type''
1>.\SFS.cpp(7) : error C2065: 'i' : undeclared identifier
1>.\SFS.cpp(7) : error C2143: syntax error : missing ';' before ')'
1>.\SFS.cpp(7) : error C2143: syntax error : missing ';' before ')'
1>.\SFS.cpp(7) : error C2143: syntax error : missing ';' before '{'
1>.\SFS.cpp(8) : error C2653: 'std' : is not a class or namespace name
1>.\SFS.cpp(8) : error C2065: 'cout' : undeclared identifier
1>.\SFS.cpp(8) : error C2065: 'features' : undeclared identifier
1>.\SFS.cpp(8) : error C2065: 'i' : undeclared identifier
1>Build log was saved at "file://c:\Users\Ola\Documents\Visual Studio 2008\Projects\SFS\SFS\Debug\BuildLog.htm"
1>SFS - 18 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
Why is that? And, how can I solve it out?
Thanks.
It has something to with prerecompiled headers and stdafx.h. What happens if you remove the line #include "stdafx.h"
?
Topic archived. No new replies allowed.