在c ++ builder中编译c ++的问题

Car*_*los 1 c++ compiler-errors c++builder

我为大学任务编写了一个C++程序.我在我的Mac上运行了Netbeans 6.8,代码运行顺畅,没有警告,错误或问题/错误.但是,当使用CodeGear RAD Studio 2009(C++ Builder)在Windows计算机上进行编译和运行时,会出现几个错误.

[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'
Run Code Online (Sandbox Code Playgroud)

这些是我正在使用的头文件

#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;
Run Code Online (Sandbox Code Playgroud)

什么是产生错误的想法以及如何解决?

小智 5

你需要:

#include <string>
Run Code Online (Sandbox Code Playgroud)

它是:

#include <windows.h>
Run Code Online (Sandbox Code Playgroud)

虽然我怀疑你需要它.

您的代码在一个平台而不是另一个平台上工作的原因是,在第一个平台上,其他库头中的一个包含<string>自身.C++标准未指定此行为,因此唯一安全的规则是:

如果您使用类或函数,请始终在代码中明确#include该类或函数的标头.