标题:涉及类于对象的小程序,不知道错哪,求解
只看楼主
飘羽
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2010-12-24
结帖率:100%
已结贴  问题点数:20 回复次数:3 
涉及类于对象的小程序,不知道错哪,求解
#include <iostream>
using namespace std;
class Salary{
    private:
      double Wage,Subsidy,Rent,WaterFee,ElecFee;
    public:
      Salary(double a,double b,double c,double d,double e){Wage=a;Subsidy=b;Rent=c;WaterFee=d;ElecFee=e;}
      Salary(){Wage=0;Subsidy=0;Rent=0;WaterFee=0;ElecFee=0;}
      void setWage(double a){Wage=a;}
      void setSubsidy(double b){Subsidy=b;}
      void setRent(double c){Rent=c;}
      void setWaterFee(double d){WaterFee=d;}
      void setElecFee(double e){ElecFee=e;}
      double getWage(){return Wage;}
      double getSubsidy(){return Subsidy;}
      double getRent(){return Rent;}
      double getWaterFee{return WaterFee;}
      double getElecFee(){return ElecFee;}
      double RealSalary(Salary s);
};

double RealSalary(Salary s)
{
    double x;
    x=s.getWage()+s.getSubsidy()-s.getRent()-s.getWaterFee-s.getElecFee();
    return x;
}

void main()
{
    Salary s;
    Salary s1(10,124,10,45,4);
    cout<<"RealSalary(s)"<<endl;
}
         
搜索更多相关主题的帖子: private 对象 
2011-03-22 15:46
bccn250
Rank: 5Rank: 5
等 级:职业侠客
帖 子:154
专家分:379
注 册:2010-5-25
得分:15 
告诉你一件非常悲哀的事情:是语法错误

#include <iostream>
using namespace std;
class Salary{
    private:
      double Wage,Subsidy,Rent,WaterFee,ElecFee;
    public:
      Salary(double a,double b,double c,double d,double e){Wage=a;Subsidy=b;Rent=c;WaterFee=d;ElecFee=e;}
      Salary(){Wage=0;Subsidy=0;Rent=0;WaterFee=0;ElecFee=0;}
      void setWage(double a){Wage=a;}
      void setSubsidy(double b){Subsidy=b;}
      void setRent(double c){Rent=c;}
      void setWaterFee(double d){WaterFee=d;}
      void setElecFee(double e){ElecFee=e;}
      double getWage(){return Wage;}
      double getSubsidy(){return Subsidy;}
      double getRent(){return Rent;}
      double getWaterFee{return WaterFee;}    //这个函数没加括号
      double getElecFee(){return ElecFee;}
      double RealSalary(Salary s);
};

double RealSalary(Salary s)    //这里没写 Salary::
{
    double x;
    x=s.getWage()+s.getSubsidy()-s.getRent()-s.getWaterFee-s.getElecFee();    //这里调用s.setWaterFee函数的时候也没加括号
    return x;
}

void main()
{
    Salary s;
    Salary s1(10,124,10,45,4);
    cout<<"RealSalary(s)"<<endl;
}
2011-03-22 16:06
lintaoyn
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:605
专家分:2489
注 册:2009-4-8
得分:5 
以下是引用飘羽在2011-3-22 15:46:08的发言:

#include
using namespace std;
class Salary{
    private:
      double Wage,Subsidy,Rent,WaterFee,ElecFee;
    public:
      Salary(double a,double b,double c,double d,double e){Wage=a;Subsidy=b;Rent=c;WaterFee=d;ElecFee=e;}
      Salary(){Wage=0;Subsidy=0;Rent=0;WaterFee=0;ElecFee=0;}
      void setWage(double a){Wage=a;}
      void setSubsidy(double b){Subsidy=b;}
      void setRent(double c){Rent=c;}
      void setWaterFee(double d){WaterFee=d;}
      void setElecFee(double e){ElecFee=e;}
      double getWage(){return Wage;}
      double getSubsidy(){return Subsidy;}
      double getRent(){return Rent;}
      double getWaterFee(){return WaterFee;}
      double getElecFee(){return ElecFee;}
      double RealSalary(Salary s);
};

double RealSalary(Salary s)
{
    double x;
    x=s.getWage()+s.getSubsidy()-s.getRent()-s.getWaterFee()-s.getElecFee();
    return x;
}
int main()
{
    Salary s;
    Salary s1(10,124,10,45,4);
    cout<<"RealSalary(s)"<
编译器会指哪行错了

迭代的是人,递归的是神。
2011-03-22 16:06
飘羽
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2010-12-24
得分:0 
谢谢高手们
2011-03-22 17:26



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




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

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