435,254 Members | 2,418 Online
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

# getting conversion error between int and char

 P: 2 #include #include using namespace std; class Square { private: double side; public: double getArea() { return side * side; } void setSide(double s) { side = s; } // Overload + operator to add two Square objects. Square operator+(const Square& b) { Square square; square.side = side + b.side; return square; } Square operator-(const Square& b) { Square square; square.side = side - b.side; return square; } Square operator*(const Square& b) { Square square; square.side = side * b.side; return square; } Square operator/(const Square& b) { Square square; square.side = side / b.side; return square; } }; // Main function int main() { Square Square1; Square Square2; Square Square3; double area = 0.0; Square1.setSide(2.0); Square2.setSide(5.0); // Square1 area area = Square1.getArea(); cout << "Area of Square1 : " << area << endl; // Square2 area area = Square2.getArea(); cout << "Area of Square2 : " << area << endl; char op; cout << "Enter the operator: "; cin >> op; switch (op) { case '+': Square3 = Square1 + Square2; cout << Square3; break; case '-': Square3 = Square1 - Square2; cout << Square3; break; case '*': Square3 = Square1 * Square2; cout << Square3; break; default: cout << "No a valid operator"; } return 0; } Nov 2 '16 #1