1. ## using UML diagram to write a header

This is the diagram:

Integer
-number: int
+Integer():
+Integer(num: int):
+~Integer():
+getInt(): int
+operator<(Integer): bool
+operator++(): int
+operator--(): int

Here is my code, prob. not quite right but was a little confused on a few lines and the book had about 2 pages on UML which did not help me much. Some of these lines I'm not sure are right but I tried what I could from reading the book. For example the operators. If I could just get some input or maybe some help on what I need to do. Thanks

Code:
```#ifndef INTEGER_H
#define INTEGER_H

class Integer
{
private:
int number;

public:
Integer();     // Constructor
Integer(int num)
~Integer();  // Destructor
int getInt();
bool operator < (int Integer &);
int operator ++ (const Integer &);
int operator -- (const Integer &);

};
#endif```

2. I believe the UML wants:
Code:
`bool operator < (Integer& rhs);`
Code:
`bool operator < (int Integer &);`

3. rhs? and what about the operators ++ and -- . I keep getting errors "error C2675: unary '--' : 'Integer' does not define this operator or a conversion to a type acceptable to the predefined operator" for each <, ++ , and -- the same error ?

4. Your overload of operator++ and operator-- should take no arguments (prefix version), and/or a dummy int argument (postfix version). From the UML diagram, the former is the case.

5. ok thanks. I fixed those errors. Now I am getting 4 errors and they are all dealing with the bool line. Not sure what is wrong because I wrote it how I thought the diagram showed. And cpjust line of code did not help.

6. Now I am getting 4 errors and they are all dealing with the bool line. Not sure what is wrong because I wrote it how I thought the diagram showed.
Post your current code and the error messages.

7. Originally Posted by dukebdx12
rhs? and what about the operators ++ and -- . I keep getting errors "error C2675: unary '--' : 'Integer' does not define this operator or a conversion to a type acceptable to the predefined operator" for each <, ++ , and -- the same error ?
rhs is short for Right Hand Side (which is probably the most common name for the argument on the right side of a == or < or + ... operator.)

8. my code:

Code:
```#ifndef INTEGER_H
#define INTEGER_H

class Integer
{
private:
int number;

public:
Integer();   // Constructor
Integer(int num);
~Integer();  // Destructor
int getInt();
bool operator < (Integer);
int operator ++ ();
int operator -- ();

};
#endif```
and the errors messages:

Code:
```1>c: : error C2784: 'bool std::operator >(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'Integer'
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(2244) : see declaration of 'std::operator >'
1> : error C2784: 'bool std::operator >(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'Integer'
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(2057) : see declaration of 'std::operator >'
1>: error C2784: 'bool std::operator >(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'Integer'
1>        c:\program files\microsoft visual studio 9.0\vc\include\utility(93) : see declaration of 'std::operator >'
1>: error C2676: binary '>' : 'Integer' does not define this operator or a conversion to a type acceptable to the predefined operator```

9. Originally Posted by dukebdx12
my code:

Code:
```#ifndef INTEGER_H
#define INTEGER_H

class Integer
{
private:
int number;

public:
Integer();   // Constructor
Integer(int num);
~Integer();  // Destructor
int getInt();
bool operator < (Integer);
int operator ++ ();
int operator -- ();

};
#endif```
and the errors messages:

Code:
```1>c: : error C2784: 'bool std::operator >(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'Integer'
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(2244) : see declaration of 'std::operator >'
1> : error C2784: 'bool std::operator >(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'Integer'
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(2057) : see declaration of 'std::operator >'
1>: error C2784: 'bool std::operator >(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'Integer'
1>        c:\program files\microsoft visual studio 9.0\vc\include\utility(93) : see declaration of 'std::operator >'
1>: error C2676: binary '>' : 'Integer' does not define this operator or a conversion to a type acceptable to the predefined operator```
You try to use >, but you only define <.

10. Where do the errors come from? You have code that implements the class? And code that uses the class?

By the way, note that getInt() and operator< should be const member functions since they, logically, do not modify the object's state. You can consider implementing operator< as a free function (a friend, if necessary).