c++ - iostream库和gcc问题

标签 c++ gcc compiler-errors iostream

我曾尝试多次编译小型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/

相关文章:

c++ - 将初始化器列表/聚合初始化转发到 std::array 成员

c - 学习编程 nrf52840

typescript - 错误TS5056 : Cannot write file because it would be would be overwritten

java - 在 JPanel 上使用 slider 绘制二次公式

iphone - 三个else-if语句

c++ - 在提供国际化支持时,自动化单元测试中的字符串是否仍应硬编码?

c++ - fatal error : sys/statvfs. h:没有那个文件或目录

c++ - 试图在我的 C++ 代码中查找内存泄漏

linux - 在 Debian 64 位上编译和链接 32 位应用程序

c - 用户自定义静态库与可重入性