🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #964

About persistance

#964
From: Maya
Date: Tue, 04 Mar 2003 19:37
40 lines
2963 bytes
Hi!
Can someone please tell me what I am doing wrong in he below example. 
I really can't get it. I copied this from a book, and then adapted it to
my class, why is it not working?

class Date{
   int month;

   .........
public:
   void Write(std::fstream&);
   std::streampos Read(std::fstream&, std::streampos);
};

void Date::Write(std::fstream& rfs)throw(jme::Exception, jme::FileIOEx) {
    rfs.write(reinterpret_cast<char*> (&month), sizeof(month));
}
std::streampos Date::Read(std::fstream& rfs, 
                               std::streampos offset = std::ios::beg) 
                                    throw(jme::Exception, jme::FileIOEx) {
   char buffer[sizeof(size_t)];
 
   rfs.flush();
   rfs.seekp(offset);
   rfs.read(buffer, sizeof(int) );
   if(rfs.fail()){ std::cout <<  "Error\n";} // <== This gets displayed


   return rfs.tellp();

}

-- 
====================== E-Communications Canada =====================
Jorge Escalante - Software Development Coordinator.
E-Mail Policy http://www.vif.com/users/escalante/Email_Policy.html

* You cannot exercise your power to a point of humiliation of others.
* What does an elephant do when he gets a broken toe?
          -He calls a toetruck
Technical Details
Message-ID: <pan.2003.03.04.14.36.57.758394.9993@canada.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!nntp.vif.com!news.vif.com.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,5f38195f967c6dbb,start
X-Google-Attributes: gid11318c,public
X-Google-Thread: 114592,5f38195f967c6dbb,start
X-Google-Attributes: gid114592,public
X-Google-Thread: fa69e,5f38195f967c6dbb,start
X-Google-Attributes: gidfa69e,public
X-Google-ArrivalTime: 2003-03-04 11:36:47 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!nntp.vif.com!news.vif.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 04 Mar 2003 13:36:42 -0600
From: Maya <escalante@canada.com>
Subject: About persistance
Date: Tue, 04 Mar 2003 14:37:02 -0500
Newsgroups: gnu.gcc.help,borland.public.cpp.borlandcpp,alt.comp.lang.learn.c-c++
Reply-To: gnu.gcc.help
Organization: NOME
Message-ID: <pan.2003.03.04.14.36.57.758394.9993@canada.com>
User-Agent: Pan/0.11.2 (Unix)
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Comment-To: ALL
Cache-Post-Path: www.vif.com!unknown@ip216-239-79-225.vif.net
X-Cache: nntpcache 2.4.0b4 (see http://www.nntpcache.org/)
Lines: 40
NNTP-Posting-Host: 216.239.64.141
X-Trace: sv3-x3fIyl/vzaH7OYZ0xsLx7eirgAHjZ5Yem6q20PJmOKnaavuO4QU+6znss2D4LZ2xTspV233/dEPitxd!ZLuRp350nmWxvMznlMl6g8pInxUyCzq+h6gPFxqiHdeeALbQ1Y9fIVpzXiM5yZmsic+eNllc8sn5!6yKJpKKr0Kg=
X-Complaints-To: abuse@vif.com
X-DMCA-Complaints-To: abuse@vif.com
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.1