Is there any way that you can pass values from your int main function, say content in a file, to a class outside the function?
I tried doing something like this, not my actual code,this would always send me something not in the file.
#include<fstream>
#include<iostream>
class Function
{
private:
inputfile;
public:
int sum;
int x;
int addition();
};
int Function::addition()
{
int sum=0
inputfile>>x
sum= sum+x;
cout<<sum;
}
int main()
{
Function add;
int x;
string filename;
ifstream inputfile;
cout<<filename;
inputfile.open(filename, ios::in)
if (inputfile.is_open())
{
inputfile>>x;
add.addition();
}
}