2010-03-17 4 views
1

대학 과제를위한 C++ 프로그램을 작성했습니다. 내 Mac에서 실행되는 Netbeans 6.8을 사용했으며 코드가 부드럽게 실행되며 경고, 오류 또는 문제/버그가 발생하지 않습니다. 그러나 CodeGear RAD Studio 2009 (C++ Builder)를 사용하여 Windows 컴퓨터에서 컴파일하고 실행할 때 몇 가지 오류가 발생합니다.C++ 빌더에서 C++ 컴파일 문제

[BCC32 Error] main.cpp(51): E2094 'operator<<' not implemented in type 'ostream' for arguments of type 'string' 
[BCC32 Error] main.cpp(62): E2093 'operator==' not implemented in type 'string' for arguments of the same type 
[BCC32 Error] main.cpp(67): E2093 'operator==' not implemented in type 'string' for arguments of the same type 
[BCC32 Error] main.cpp(112): E2093 'operator==' not implemented in type 'string' for arguments of the same type 
[BCC32 Error] main.cpp(121): E2094 'operator<<' not implemented in type 'ostream' for arguments of type 'string' 
[BCC32 Error] main.cpp(130): E2093 'operator==' not implemented in type 'string' for arguments of the same type 
[BCC32 Error] main.cpp(133): E2094 'operator<<' not implemented in type 'ostream' for arguments of type 'string' 
[BCC32 Error] main.cpp(139): E2094 'operator<<' not implemented in type 'ostream' for arguments of type 'string' 
[BCC32 Error] main.cpp(153): E2094 'operator<<' not implemented in type 'fstream' for arguments of type 'string' 
[BCC32 Error] main.cpp(199): E2094 'operator>>' not implemented in type 'fstream' for arguments of type 'string' 
[BCC32 Error] main.cpp(219): E2094 'operator>>' not implemented in type 'istream' for arguments of type 'string' 
[BCC32 Error] main.cpp(231): E2094 'operator>>' not implemented in type 'istream' for arguments of type 'string' 
[BCC32 Error] main.cpp(240): E2094 'operator>>' not implemented in type 'istream' for arguments of type 'string' 
[BCC32 Error] main.cpp(262): E2094 'operator>>' not implemented in type 'istream' for arguments of type 'string' 
[BCC32 Error] main.cpp(264): E2094 'operator>>' not implemented in type 'istream' for arguments of type 'string' 

이 헤더 파일은

#include <iostream> 
#include <fstream> 
#include <cmath> 
#include <stdio> 
#include <windows> //I added this one just to check and still does not work (I didnt have it on Netbeans/Mac) 
using namespace std; 

오류를 생산하고 나는 그것을 어떻게 해결할 수있는 어떤 아이디어를 사용하고 있습니까?

+2

추측 : 당신이 필요로''을 #include를 –

답변

5

당신이 필요합니다

#include <string> 

과는 다음과 같습니다

#include <windows.h> 

나는 당신이 그것을 필요로 의심하지만.

코드가 다른 플랫폼이 아닌 다른 플랫폼에서 작동 한 이유는 첫 번째 플랫폼에서 다른 라이브러리 헤더 중 하나가 <string> 이었기 때문입니다. 유일한 안전 규칙 그래서이 동작은 C++ 표준에 의해 지정되지 않은 : 당신은 클래스 또는 함수를 사용하는 경우

는 항상 명시 적으로 코드에서 그 클래스 또는 함수의 헤더 을 #include를.

0

당신은 string 개체에서이 작업을 수행 할 수 있습니다

to_string < char,std::string::traits_type,std::string::allocator_type>()