标题:一道关于类的问题
取消只看楼主
枫xby
Rank: 5Rank: 5
等 级:职业侠客
威 望:8
帖 子:82
专家分:371
注 册:2014-10-19
结帖率:71.43%
已结贴  问题点数:10 回复次数:0 
一道关于类的问题
代码如下  求各位指导

#include<iostream>
using namespace std;
int main(){
    double f,g;
    double l,m,n;
   cout<<"请输入两个双精度浮点数:";
   cin>>f>>g;
   cout<<"请输入三个精度浮点数:";
   cin>>l>>m>>n;
   Compare compare1(f,g);
   Compare compare2(l,m,n);
   compare1.min();
   compare2.min_1();
   compare1.show();
   compare2.show_1();

   return 0;
   

}
class Compare
{  private:
     double t1;
     double t2;
     double x,y,z;
     double a,b;
  
   public:
      Compare(double ,double,double);
      Compare(double,double);
   
      void min();
      void min_1();
      void show();
      void show_1();

};
void Compare::min()
{   if(a>b)
       t1=b;
    else
       t1=b;
}
void Compare::min_1()
{
     double temp;
     if(x>y)
         temp=y;
     else
         temp=x;
     if(z>temp)
         t2=temp;
     else
         t2=z;

}
void Compare::show(){
    cout<<t1;
}
void Compare::show_1(){
    cout<<t2;
}
Compare::Compare(double f,double g)
{
    a=f;
    b=g;
}
Compare::Compare(double l,double m,double n)
{
    x=l;
    y=m;
    z=n;
}

错误显示为
D:\C++\test1\test1.cpp(10) : error C2065: 'Compare' : undeclared identifier
D:\C++\test1\test1.cpp(10) : error C2146: syntax error : missing ';' before identifier 'compare1'
D:\C++\test1\test1.cpp(10) : error C2065: 'compare1' : undeclared identifier
D:\C++\test1\test1.cpp(11) : error C2146: syntax error : missing ';' before identifier 'compare2'
D:\C++\test1\test1.cpp(11) : error C2065: 'compare2' : undeclared identifier
D:\C++\test1\test1.cpp(12) : error C2228: left of '.min' must have class/struct/union type
D:\C++\test1\test1.cpp(13) : error C2228: left of '.min_1' must have class/struct/union type
D:\C++\test1\test1.cpp(14) : error C2228: left of '.show' must have class/struct/union type
D:\C++\test1\test1.cpp(15) : error C2228: left of '.show_1' must have class/struct/union type
搜索更多相关主题的帖子: private include double return 
2015-05-02 20:14



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-444762-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.234787 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved