Is ifs is a member function of ifstream class

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2004
Posts: 1
Reputation: psk is an unknown quantity at this point 
Solved Threads: 0
psk psk is offline Offline
Newbie Poster

Is ifs is a member function of ifstream class

 
0
  #1
Jul 23rd, 2004
Hi all,

can anyone tell me whether ifs function is a member function of ifstream.

in the statements below the ifs has been used like ........

ifstream ifs( g_pSystemEnvironment->GetTotAlmCountFileName() );

ifs >> m_nNoOfTotalAlarm;

i am not able to understand the code. could anyone help me out of it.

Thanx in advance.
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 141
Reputation: meabed is on a distinguished road 
Solved Threads: 3
Team Colleague
meabed's Avatar
meabed meabed is offline Offline
Junior Poster

Re: Is ifs is a member function of ifstream class

 
0
  #2
Jul 23rd, 2004
look at this example ...
  1. #include <fstream> β€’ <fstream> header file
  2. using namespace std; – Use ifstream for input
  3. int main() – Use ofstream for output
  4. {
  5. ifstream ifs;
  6. ifs.open(β€œin.txtβ€?); β€’ Other methods
  7. ofstream ofs(β€œout.txtβ€?); – open, is_open, close
  8. if (ifs.is_open() && – getline
  9. ofs.is_open()){ – seekg, seekp
  10. int i; β€’ File modes
  11. ifs >> i; – in, out, ate, app, trunc, binary
  12. ofs << i;
  13. }
  14. ifs.close();
  15. ofs.close();
  16. return 0;
  17. }
--------------------------------------------------------------------------------
  1. #include <iostream> β€’ <sstream> header file
  2. #include <fstream> – Use istringstream for input
  3. #include <sstream> – Use ostringstream for output
  4. using namespace std;
  5. int main() { β€’ Useful for scanning input
  6. ifstream ifs(β€œin.txtβ€?); – Get a line from file into string
  7. if (ifs.is_open()) – Wrap string in a stream
  8. {string line1, word1; – Pull words off the stream
  9. getline(ifs, line1); β€’ Useful for formatting output
  10. istringstream iss(line1); – Use string as format buffer
  11. iss >> word1; – Wrap string in a stream
  12. cout << word1 << endl; – Push formatted values into stream
  13. } – Output formatted string to file
  14. return 0;
  15. }
Real Eyes Realize Real Lies
My Resume
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,334
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 234
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Is ifs is a member function of ifstream class

 
0
  #3
Jul 23rd, 2004
Originally Posted by psk
can anyone tell me whether ifs function is a member function of ifstream.
  1. ifstream ifs( g_pSystemEnvironment->GetTotAlmCountFileName() );
i am not able to understand the code. could anyone help me out of it.
Here ifs is not a function. It is an object of type ifstream. It is being instantiated using a parameterized constructor (passing the result of the g_pSystemEnvironment->GetTotAlmCountFileName function as the parameter) instead of the default constructor.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC