注册 登录
编程论坛 C++教室

有关C++的几个问题

专属宝贝 发布于 2010-07-26 18:21, 531 次点击
在集成环境VC++6.0中有些错误可以帮忙解决下吗?我还没有入门,所以有很多不懂的地方。
错误1:eh.h is only for C++
#include<iostream.h>
#include<math.h>

double max(doubke x,double y)
{
    if(x>y)
        return x;
    else
        return y;
}

void main()
{
    double a,b,c;
    cout<<"Input two numbers:\n";
     cin>>a>>b;

      c=max(a,b);
      
       cout<<"the squart of maximum="<<sqrt(c)
}

错误2:error C2065: 'cin' : undeclared identifier
错误3:error C2297: '<<' : illegal, right operand has type 'char [20]'
错误4: error C2296: '>>' : illegal, left operand has type 'double '
warning C4013: 'max' undefined; assuming extern returning int
4 回复
#2
rainbow12010-07-26 20:19
第二个问题有两种解决办法:
1、在cout和cin前加上std::
2、在第三行加上
using namespace std;

第一个问题不太明白,因为没有
eh.h
这么一个东西,应该不会出现这个错误。


子函数写错了,不是
doubke
应该是
double

还有,建议把
#include <iostream.h>
改成
#include <iostream>
估计第三第四个问题就不会出现了。
#3
gq1987182010-07-27 08:54
程序代码:
#include<iostream>
#include<cmath> //第一个错误
using namespace std;
double max(double x,double y)//第二个错误
{
    if(x>y)
        return x;
    else
        return y;
}

void main()
{
    double a,b,c;
    cout<<"Input two numbers:\n";
     cin>>a>>b;

      c=max(a,b);
      
       cout<<"the squart of maximum="<<sqrt(c);//第三个错误
}
错误地方已经指出来了
#4
专属宝贝2010-07-27 20:55
回复 2楼 rainbow1
谢谢侠哥啊!哈哈。。。以后多多指教!
#5
专属宝贝2010-07-27 20:57
回复 3楼 gq198718
非常感谢!
1