This comes down to my 3rd paragraph from my previous post.

Where is outfile declared that is visible in FRACTION.CPP? It is not declared in the file itself and it certainly isn't declared in fstream. FRACTION.H doesn't declared it or include a file that does. That only leaves StdAfx.h and since you are getting the error I assume it is not declared in there.

If you want to use outfile in Fraction::print then you will need to declare it somewhere that is visible to Fraction::print.

However I come back to my previous point, this is really poor programming style, it would be better to declare Fraction::print as

void Fraction::print(ostream& out) const
{
	out<<numerator<<"/"<<denominator;
}

and pass outfile into print as a parameter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.