help with errors

help with errors

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #ifndef FRACTIONTYPE_H
#define FRACTIONTYPE_H
#include <iostream>
using namespace std;
class fractionType
{
    friend ostream& operator<< (ostream&, const fractionType&);
    friend istream& operator>> (istream, fractionType&);
    public:
        void setFraction(int num, int den);
        fractionType(int num = 0 , int den = 1);
        bool operator ==(const fractionType&) const;
        bool operator !=(const fractionType&) const;
        bool operator <= (const fractionType&) const;
        bool operator < (const fractionType&) const;
        bool operator >= (const fractionType&) const;
        bool operator >(const fractionType&) const;

        fractionType operator +(const fractionType&);
        fractionType operator -(const fractionType&);
        fractionType operator *(const fractionType&);
        fractionType operator /(const fractionType&);
private:
        int numerator;
        int denominator;
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <iostream>
#include <iomanip>
#include "fractiontype.h"
using namespace std;
fractionType::fractionType(int num ,int den)
{
    numerator =num;

    if(den == 0)
    {
        cout <<"denominator cannot be a zero" << endl;
         denominator =1;
    }
    else
        denominator =den;

}
void fractionType::setFraction(int num , int den)
{
    numerator =num;

    if(den == 0)
    {
        cout << "denominator cannot be zero" << endl;
        denominator = 1;

    }
    else
        denominator =den;
}
ostream& operator <<(ostream& object, const fractionType& myFraction)
{
     object << myFraction.numerator << "/" << myFraction.denominator;
     return object;
}
istream& operator >> (istream& object2, const fractionType& myFraction)
{
    char ch;
    object2 >> myFraction.numerator;
    object2 >> ch;
    object2 >> myFraction.denominator;
    return object2;
}
bool fractionType::operator==(const fractionType& rightFraction) const
{
    return(numerator* rightFraction.denominator == denominator *rightFraction.numerator);
}
bool fractionType::operator!=(const fractionType& rightFraction) const
{
    return(numerator * rightFraction.denominator != denominator * rightFraction.numerator);
}
bool fractionType::operator<(const fractionType& rightFraction) const
{
    return(numerator * rightFraction.denominator < denominator * rightFraction.numerator);
}
bool fractionType::operator<=(const fractionType& rightFraction) const
{
    return(numerator * rightFraction.denominator <= denominator * rightFraction.numerator);
}
bool fractionType::operator>(const fractionType& rightFraction) const
{
    return(numerator * rightFraction.denominator > denominator * rightFraction.numerator);
}
bool fractionType::operator>=(const fractionType& rightFraction) const
{
    return(numerator*rightFraction.numerator >= denominator*rightFraction.numerator);
}
fractionType fractionType::operator+(fractionType rightFraction)
{
    fractionType temp;

    temp.numerator =numerator*rightFraction.denominator+rightFraction.numerator *denominator;

    temp.denominator = denominator * rightFraction.denominator;

    return temp;
} fractionType fractionType::operator*(fractionType rightFraction)
{
    fractionType temp;

    temp.numerator =numerator* rightFraction.numerator;
    temp.denominator =denominator*rightFraction.denominator;

    return temp;
}
 fractionType fractionType::operator-(fractionType rightFraction)
{
   fractionType temp;

   temp.numerator =numerator*rightFraction.denominator - rightFraction.numerator * denominator;

   temp.denominator = denominator * rightFraction.denominator;

   return temp;

}
 fractionType fractionType::operator/(fractionType rightFraction)
{
    fraction temp;

    if(rightFraction.numerator == 0)
    {
        cout << "cannot divide by zero " << endl;
        return *this;
    }
    else
    {
        temp.numerator=numerator * rightFraction.denominator
        temp.denominator = rightFraction.numerator * denominator;

        return temp;
    }
}
this are my errors please help

'int fractionType::numerator' is private
int numerator;
^
line: 39 error: within this context
object2 >> myFraction.numerator;
^
error: 'int fractionType::denominator' is private
int denominator;
^
line41 error: within this context
object2 >> myFraction.denominator;
i went and fix the errors now these are the only errors
Last edited on
Help me for getting correct answere.
in this program i want to get answere with tax. But tax function is not working.

#include <iostream>
using namespace std;
struct calls
{
int noOfCalls;
float result;
float condition();
float resultt();
};
float calls :: condition()
{
if (noOfCalls >= 0 && noOfCalls <= 100)
{
result = (noOfCalls + 0.80) * 250;
}
else if (noOfCalls >= 100 && noOfCalls <= 250)
{
result = (noOfCalls + 1.00) * 350;
}
else if (noOfCalls >= 250)
{
result = (noOfCalls + 1.25) * 500;
}
return result;
}
float calls::resultt()
{
if (result >= 1000 && result <= 1500)
result = result *(7 / 100 + 1);
else if (result >= 1501 && result <= 2000)
result = result *(10 / 100 + 1);
else if (result >= 2001)
result = result *(15 / 100 + 1);
return result;

}
void main()
{
calls e1;
e1.result = 0;
cout << "Enter NO of Calls ";
cin >> e1.noOfCalls;
e1.condition();
e1.resultt();
cout << " Your Bill is = " << e1.result;
system("pause");
}
Topic archived. No new replies allowed.