I omitted much of my code and much of my original input file just to make it easier and simpler to read, and to focus on one specific problem.
Each time I try and compile this code:
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
void readExpression(ostream &fin, double operand1, char oepratr, double operand2);
int main()
{
double operand1,
operand2;
char operatr;
ifstream fin;
fin.open("inp.txt");
readExpression(fin, operand1, operatr, operand2);
fin.close();
return 0;
}
void readExpression(ostream &fin, double operand1, char operatr, double operand2)
{
cin >> operand1 >> operatr >> operand2;
}
This is the input file:
2.0 + 2.0
I always get the error that I have
error: invalid initialization of reference of type 'std::ostream& {aka std::basic_ostream<char>&}' from expression of type 'std::ifstream {aka std::basic_ifstream<char>}'|
I'm not sure what I'm doing wrong. I've been at this for hours and still haven't found a solution, after countless hours of researching. I am fairly new to cpp and only have experience in other language, which is why I am struggling with what seems like an elementary concept. Any help is greatly appreciated.