iostream 库和 gcc 的问题
Problems with iostream library and gcc
我试过多次编译一个小的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++程序,但每次我用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++ 程序。