how do i create a set method to get the fstream input file.

in need to be able to define the file location in the main method.

class a
{
private:
	ifstream fileOne;
	ofstream report1;
	
	
public:
	void setinput(std::ifstream& in);
	void setoutput(std::ofstream& out);
	
};

how can i code these set methods.

Thank you

how do i create a set method to get the fstream input file.

in need to be able to define the file location in the main method.

class a
{
private:
	ifstream fileOne;
	ofstream report1;
	
	
public:
	void setinput(std::ifstream& in);
	void setoutput(std::ofstream& out);
	
};

how can i code these set methods.

Use pointers:

class A // Better use capitalized names for your classes
{
public: // Better place public interface first
  A():inFile(0),report(0) {}
  void setinput(std::ifstream& in) { inFile = ∈ }
  void setoutput(std::ofstream& out)
  {
    outFile = &out;
  }
  void report();
  ...
private: // it's not so interesting for the class user
  ifstream*  inFile;
  ofstream* outFile;
};
void A::report()
{
  if (outFile) {
    ofstream& f = *outFile;
    f << ...;
    ...
  } // else no output file settings...
}

Be careful: you must provide these fstream existence while A::report is working. So it's not a very robust architecture (no matter with or w/o pointers).

Comments
THank you for the Help:)

Thank you very much working perfectly i forgot about the pointers :)hehe

and one more thing how do i set the input file to "aa.txt" in the main method

and one more thing how do i set the input file to "aa.txt" in the main method

ifstream infile("aa.txt");
// or
infile.open("aa.txt");

;)hehe

This question has already been answered. Start a new discussion instead.