Implementing Operator Overloading with Logarithms in C++
- by Jacob Relkin
Hello my friends,
I'm having some issues with implementing a logarithm class with operator overloading in C++.
My first goal is how I would implement the changeBase method, I've been having a tough time wrapping my head around it.
My secoond goal is to be able to perform an operation where the left operand is a double and the right operand is a logarithm object.
Here's a snippet of my log class:
// coefficient: double
// base: unsigned int
// number: double
class _log {
 double coefficient, number;
 unsigned int base;
public:
 _log() {
  base = rand();
  coefficient = rand();
  number = rand();
 }
 _log operator+ ( const double b ) const;
 _log operator* ( const double b ) const;
 _log operator- ( const double b ) const;
 _log operator/ ( const double b ) const;
 _log operator<< ( const _log &b );
 double getValue() const;
 bool changeBase( unsigned int base );
};
You guys are awesome, thank you for your time.