plz i m having error at line 71 and 83

#include <iostream>
#include <stdlib.h>
using namespace std;



      class expense
      {
            private:
                    int income;
                    int gbill;
                    int ebill;
                    int wbill;
                    int saving;
                    
                    public:
                           expense(int, int, int);
                           int display();
                           void setTotalIncome(int);
                           void setEBill(int);
                           void setWBill(int);
                           void setGBill(int);
                            
                           int getEBill();
                           int getWBill(); 
                           int getGBill(); 
                           friend int addBills(expense m);
                           };
 expense::expense(int eb,int gb, int wb)
 {
                      ebill=eb;
                      wbill=wb;
                      gbill=gb;
                      }                          
int expense::display()
{
     cout <<"expense"<<","<<getEBill()<<","<<getGBill()<<","<<getWBill();
     }
void expense::setTotalIncome(int i)
{
     income=i;                            
}
void expense::setEBill(int i)
{
     ebill=i;
     }
void expense::setGBill(int i)
{
     gbill=i;
     
     }
void expense::setWBill(int i)
{
     wbill=i;
     }
int expense::getEBill()
{
     return ebill;                            
}
int expense::getGBill()
{
     return gbill;
     }
int expense::getWBill()
{
     return wbill;
            }
int addBills(expense m)
{
    
    return (m.ebill+m.gbill+.m.wbill);
}
int main()
{
int totalIncome;
int e;
int w;
int g;
cin>>e;
cin>>w;
cin>>g;
    expense m1(e,g,w);
    cout <<"add"<<addBills(expense m1);
    m1.display();
}

Recommended Answers

All 5 Replies

what are the error messages?

>>cout <<"add"<<addBills(expense m1);
The parameters should not contain the dta type, just variable names, such as cout <<"add"<<addBills(m1);

please chk my saving function is not working properly

#include <iostream>
#include <stdlib.h>
using namespace std;



      class expense
      {
            private:
                    int income;
                    int gbill;
                    int ebill;
                    int wbill;
                    int saving;
                    
                    public:
                           expense(int, int, int);
                           int display();
                           void setTotalIncome(int);
                           void setEBill(int);
                           void setWBill(int);
                           void setGBill(int);
                            
                           int getEBill();
                           int getWBill(); 
                           int getGBill(); 
                           friend int addBills(expense m);
                           friend int income(expense m);
                           friend int saving(expense m);
                           };
 expense::expense(int eb,int gb, int wb)
 {
                      ebill=eb;
                      wbill=wb;
                      gbill=gb;
                      }                          
int expense::display()
{
     cout <<"expense"<<","<<getEBill()<<","<<getGBill()<<","<<getWBill();
     }
void expense::setTotalIncome(int i)
{
     income=i;                            
}
void expense::setEBill(int i)
{
     ebill=i;
     }
void expense::setGBill(int i)
{
     gbill=i;
     
     }
void expense::setWBill(int i)
{
     wbill=i;
     }
int expense::getEBill()
{
     return ebill;                            
}
int expense::getGBill()
{
     return gbill;
     }
int expense::getWBill()
{
     return wbill;
            }
int addBills(expense m)
{
    
    return (m.ebill+m.gbill+m.wbill);
}
int income (expense m)
{
    cout <<"please enter ur total salary";
    cin>>m.income;
}
int saving (expense m)
{
    return (m.income-(m.ebill+m.gbill+m.wbill));
}
int main()
{
int totalIncome;
int e;
int w;
int g;
cin>>e;
cin>>w;
cin>>g;
    expense m1(e,g,w);
    income(m1);
    cout <<"add"<<addBills(m1);
    cout <<"saving "<<saving (m1);
    m1.display();
}

You are using pass-by-value semantics for passing method parameters as a result the changes you make, to the object, inside the functions have not effect on the actual object. Pass the parameters by reference and try.

how can i do dat plz guide me in detail

how can i do dat plz guide me in detail

I don't think I can guide you in detail, it is a very basic concept of C++ and you should understand that thoroughly before you proceed. You can use Google to search for "pass-by-value + pass-by-reference + C++" and would surely get some good links. Then try it out and post back if you find any difficulties.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.