Visual Studio를 사용하지 않고 일부 코드를 먼저 컴파일하십시오. mingw를 설치하고 환경 경로 변수를 설정하십시오. 하나의 소스 파일과 입력의 디렉토리로 이동, cmd를 껍질을 개방함으로써mingw 컴파일러 오류
#include <iostream>
#include <vector>
int main() {
typedef std::vector<int> Container;
typedef std::vector<int>size_type size;
typedef std::vector<int>iterator iter;
Container container;
for (size i = 0; i != 1000000; ++i) {
container.push_back(i);
}
for (iter i = container.begin(); i != container.end(); ++i) {
std::cout << *i << " " << std::endl;
}
system("PAUSE");
return 0;
}
: 그럼이 코드를 컴파일하려고
g++ main.cpp
그러나 다음과 같이 나는 오류 메시지를 많이 얻을 :
main.cpp: In function 'int main()':
main.cpp:6:35: error: expected initializer before 'size'
main.cpp:7:34: error: expected initializer before 'iter'
main.cpp:11:6: error: 'size' was not declared in this scope
main.cpp:11:11: error: expected ';' before 'i'
main.cpp:11:18: error: 'i' was not declared in this scope
main.cpp:15:6: error: 'iter' was not declared in this scope
main.cpp:15:11: error: expected ';' before 'i'
main.cpp:15:34: error: 'i' was not declared in this scope
main.cpp:19:15: error: 'system' was not declared in this scope
내가 아프게 뭔가 분명한 것을 여기에 놓치고 있습니까? 감사. 에
아, 고마워. main.cpp : 함수에서 'int main()': main.cpp : 19 : 15 : 오류 :이 범위에서 '시스템'이 선언되지 않았습니다. –
음,'system()'은 posix 함수입니다. , 그리고 당신은 창문 위에서 개발 중입니다. 'std :: cin'을 사용하여 키를 누를 때까지 기다리는 것과 같이 프로그램을 일시 중지하는 다른 방법을 찾아야합니다. – Griwes
고마워 ... 지금 컴파일 :) 메모장 C++에서 작성했는데 일반적으로 비주얼 스튜디오가 문제를 지적했을 것입니다. –