I have a feeling this question might be a no brainer to all you. But is it possible to convert a string object to an istream obj. Because what I need to do is read the string expression and then calculate it using the "read_and_evaluate(istream&)" method in my if else statement. Any help would be grateful.
#include <cstdlib> // Provides EXIT_SUCCESS
#include <iostream> // Provides cin, cout
#include <stack> // Provides stack
#include <string> // Provides string
#include "Calc.h"
using namespace std;
int main( )
{
Equation calculate;
string user_input;
double answer;
int x;
cout << "Type a string with some parentheses:\n";
getline(cin, user_input);
if (calculate.is_balanced(user_input))
{
cout << "Those parentheses are balanced.\n";
answer = calculate.read_and_evaluate(*******);
cout << "That evaluates to " << answer << endl;
}
else
{
cout << "Those parentheses are not balanced.\n";
}
cout << "all done.\n";
return EXIT_SUCCESS;
}