User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 397,850 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,329 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 3080 | Replies: 2
Reply
Join Date: Jul 2004
Posts: 1
Reputation: psk is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
psk psk is offline Offline
Newbie Poster

Is ifs is a member function of ifstream class

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2004
Location: Egypt - Cairo
Posts: 129
Reputation: meabed is on a distinguished road 
Rep Power: 5
Solved Threads: 2
Colleague
meabed's Avatar
meabed meabed is offline Offline
Junior Poster

Re: Is ifs is a member function of ifstream class

  #2  
Jul 23rd, 2004
look at this example ...
#include <fstream>            β€’ <fstream> header file
using namespace std;         – Use ifstream for input
int main()                         – Use ofstream for output
{
ifstream ifs;                      
ifs.open(β€œin.txtβ€?);              β€’ Other methods 
ofstream ofs(β€œout.txtβ€?);     – open, is_open, close    
if (ifs.is_open() &&            – getline
ofs.is_open()){                – seekg, seekp  
int i;                              β€’ File modes
ifs >> i;                          – in, out, ate, app, trunc, binary
ofs << i; 
}
ifs.close();
 ofs.close();
return 0;
}
--------------------------------------------------------------------------------
#include <iostream>         β€’ <sstream> header file
#include <fstream>          – Use istringstream for input
#include <sstream>          – Use ostringstream for output
using namespace std;       
int main() {                      β€’ Useful for scanning input
ifstream ifs(β€œin.txtβ€?);          – Get a line from file into string
if (ifs.is_open())                – Wrap string in a stream
{string line1, word1;          – Pull words off the stream
getline(ifs, line1);              β€’ Useful for formatting output
istringstream iss(line1);      – Use string as format buffer
iss >> word1;                   – Wrap string in a stream
cout << word1 << endl;     – Push formatted values into stream
}                                    – Output formatted string to file
return 0;
}
Real Eyes Realize Real Lies
Reply With Quote  
Join Date: Apr 2004
Posts: 3,462
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 16
Solved Threads: 138
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

  #3  
Jul 23rd, 2004
Originally Posted by psk
can anyone tell me whether ifs function is a member function of ifstream.
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 8:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC