我曾尝试多次编译小型C++程序,但每次使用gcc进行编译时都会失败。
我正在使用Cygwin64,这是代码:
#include <iostream>
#include <string.h>
using namespace std;
#define MAX 100
using namespace std;
#define MAX 100
int main(){
int n;
cout<<"Caantidad de elementos a ingresar";
cin>>n;
if(n<=0) {
cout<<"Elementos ingresador no válidos"<<endl;
} if(n>MAX) {
cout<<"La cantidad ingresada no es válida, Maximo "<<MAX<<" : " <<endl;
return n;
}
}
错误是:
$ gcc nuevo.cpp /tmp/ccurFCPF.o:nuevo.cpp:(.text+0x1c): referencia a `std::basic_ostream >& std::operator<< > std::basic_ostream >&, char const*)' sin definir
谢谢您的帮助
最佳答案
代替gcc
,使用g++
。 gcc
用于C程序。 g++
用于C++程序。
关于c++ - iostream库和gcc问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30382680/