3 ms·
No. But you can put a smart pointer object on the stack. #include <boost/smart_ptr.hpp> #include <fstream> using namespace boost; using namespace std;
by wedesoft 17y ago
No. But you can put a smart pointer object on the stack.
#include <boost/smart_ptr.hpp>
#include <fstream>
using namespace boost;
using namespace std;
int main()
{
{
shared_ptr< fstream > f( new fstream( "test.txt", ios::out ) );
*f << "Hello" << endl;
} // File gets closed
// ...
return 0;
}