iostream库和gcc的问题

rfc*_*bal -1 c++ gcc iostream compiler-errors

我曾尝试多次编译一个小型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;        
     }

}
Run Code Online (Sandbox Code Playgroud)

错误是:

$ gcc nuevo.cpp /tmp/ccurFCPF.o:nuevo.cpp:(.text+0x1c):referencia a`std :: basic_ostream>&std :: operator <<> std :: basic_ostream>&,char const*) '罪恶定义

我很感激你的帮助

R S*_*ahu 6

而不是gcc,使用g++.gcc用于C程序.g++将用于C++程序.

  • @vsoftco,总是不起作用.由于某种原因,这次工作:) (2认同)