You probably miss the header file 'string'.
Just put the line
after the "#define INTEGER_H"
Ah, I see you've only included it in the .cpp file. This means you cannot use types from this header in your .h file. Include it in the .h file instead and it will work.
Your functions 'add', 'subtract', 'multiply', 'divide' are in fact operators '@=' instead of functions. Consider the following:
Code:
#ifndef INTEGER_H
#define INTEGER_H
#include <string>
class Integer{
private:
int _int;
public:
Integer(int i);
Integer(std::string astr);
int getValue() const; // const declaration
void setValue(int const& i); // const declaration of argument
Integer& operator +=(Integer const& i);
};
#endif
Code:
inline
int Integer::getValue() const
{
return _int;
}
Integer& Integer::operator+=( Integer const& p_int)
{
this->_int += p_int.getValue();
return *this;
}
#endif
Now you can implement an operator+ accordingly:
Code:
Integer operator+( Integer const& p_arg1, Integer const& p_arg2)
{
Integer result( p_arg1);
return ( result += p_arg2);
}