| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 432 人关注过本帖
标题:涉及类于对象的小程序,不知道错哪,求解
只看楼主 加入收藏
飘羽
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
帖 子:606
专家分:2499
注 册: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
快速回复:涉及类于对象的小程序,不知道错哪,求解
数据加载中...
 
   



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

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