iostream库和gcc的问题

Problems with iostream library and gcc

本文关键字:问题 gcc 库和 iostream      更新时间:2023-10-16

我试过很多次编译一个小的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/curfcpf .o:nuevo.cpp:(.text+0x1c):引用a"std:: basic_ostream>,std:: operator<& lt;> std::basic_ostream>&, char const*)' sindefinir

我很感激你的帮助

g++代替gccgcc用于C程序。g++用于c++程序