Object Oriented Programming C++ Simple Calculator
This is a beginner C++ OOP program. # include <iostream> # include <limits> # include <math.h> # include <cmath> // for log function using namespace std ; class calculator { public: double add(double a, double b){ return a+b; } double subtract (double a, double b){ return a-b; } double multiply (double a, double b){ if(a==0 && b==0){ cout<<"Error! Invalid operation!"<<endl; return std::numeric_limits<double>:: quiet_NaN (); } return a*b; } double divide (double a, double b){ if(b==0) { cout<<"Error! Cannot divide by 0!"<<endl; return std::numeric_limits<double>:: quiet_NaN (); } return a/b; } double power (double a, double b){ return pow(a,b); } double loggy (double a) { //can't be 0 or less