+3 votes
in Class 12 by kratos

List the different modes of opening a file with their meaning in C++.

1 Answer

+4 votes
by kratos
 
Best answer

The methods of opening file within C++ program

  • Opening a file using constructor
  • Opening a file using member function open() of the class

Opening a file using constructor:

The syntax for opening file for output purpose only is ofstream obj(“filename”);
Example:
ofstream fout(“results.dat”);

...