By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

can we consider fstream fin(filename), fstream to be class & fin to be class object?

P: 1
want to know about ifstream and ofstream.
Jan 30 '18 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
No you cannot.

fin is a function name. It returns an fstream object. You cannot use that object as a reference. What you do is create your own fstream object using the copy constructor of fstream. Then you can use your object as a reference.

Expand|Select|Wrap|Line Numbers
  1. fstream myobj = fin("some file name");
Jan 31 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.