c++语言的一个问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 05:03:14
#include<iostream>
#include<cmath>
void main()
{
double s;
s=log10(2);
cout<<s;
}

出现了下面这个情况:
--------------------Configuration: juedui - Win32 Debug--------------------
Compiling...
juedui.cpp
E:\C\juedui.cpp(7) : error C2065: 'cout' : undeclared identifier
E:\C\juedui.cpp(7) : error C2296: '<<' : illegal, left operand has type 'double'
E:\C\juedui.cpp(7) : error C2297: '<<' : illegal, right operand has type 'double'

main函数前面加个using namespace std看看
C++中main函数必须定义成int main(),可以自动返回值,定义成其他的要加return 0;定义成void main()是错误的
建议看看http://zhidao.baidu.com/question/24992453.html中的最佳答案

给点分。

加上
using namespace std;