Re: Library

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Feb 05 1999 - 16:43:22 MET


Hi Frederic,
If you do not provide a copy constructor for your class, rootcint
will automatically generate one. However, this automatic constructor
will not work in case your class has members of other classes that are
private.
The solution is to declare a copy constructor in your header file.
Modify your header file to look like below.

Rene Brun


#include <TObject.h>
#include <fstream.h>

class DataManager {

protected:
  ofstream Log;
  ifstream ODF;
  
public:
  DataManager();
  DataManager(char*);
  DataManager(const DataManager &);
  void ConnectLog(char*);
  void ConnectODF(char*);
  void DisConnectLog();
  void DisConnectODF();
  ClassDef(DataManager,0)
};






Frederic MACHEFERT wrote:
> 
>         Hello,
> 
> I try to create a shared library containing several personal classes and I
> have some problems including a class which is supposed to manage
> input/output on disk. The compilation of the code is correct but the
> dictionary I build doesn't compile and produce the following error message
> :
> 
> CC: "Dictionary.cxx", line 158: error: void ofstream::ofstream(const class
> ofstream&) cannot access void ios::ios(const ios&): private member (1655)
> CC: "Dictionary.cxx", line 158: error: void fstreambase::fstreambase(const
> class fstreambase&) cannot access void ios::ios(const ios&): private
> member (1655)
> CC: "Dictionary.cxx", line 158: error: void filebuf::filebuf(const class
> filebuf&) cannot access void streambuf::streambuf(const streambuf&):
> private member (1655)
> CC: "Dictionary.cxx", line 158: error: void ostream::ostream(const class
> ostream&) cannot access void ios::ios(const ios&): private member (1655)
> CC: "Dictionary.cxx", line 158: error: void ifstream::ifstream(const class
> ifstream&) cannot access void ios::ios(const ios&): private member (1655)
> CC: "Dictionary.cxx", line 158: error: void istream::istream(const class
> istream&) cannot access void ios::ios(const ios&): private member (1655)
> 
> Although I included the iostream.h, iomanip.h and fstream.h header files.
> I work on HP-UX10.20 and the root version is 2/20.06 on CC compiler.
> 
> Here is the header file of my class :
> class DataManager{
> protected:
>   ofstream Log;
>   ifstream ODF;
> public:
>   DataManager(char*);
>   void ConnectLog(char*);
>   void ConnectODF(char*);
>   void DisConnectLog();
>   void DisConnectODF();
>   ClassDef(DataManager,0)
> };
> 
> and this is the definition of one of my member functions :
> void DataManager::ConnectLog(char *name){
>   Log.open(name,ios::out);
>   if(Log.bad()){
>     cerr<<"Can't open Log file "<<name<<"\n";
>     exit(0);
>   }
>   Log<<"Connecting Log File ..."<<name<<"\n";
>   cout<<"Connecting Log File ... "<<name<<"\n";
> }
> 
> Thank you for your help,
> Frederic.
> 
> -------- Frederic Machefert ------------
> DAPNIA/SPP - Bat. 141 - Piece 26B
> CEA-SACLAY - 91191 GIF-SUR-YVETTE Cedex - FRANCE
> tel: (33) 01 69 08 46 03  fax: (33) 01 69 08 36 49
> Frederic.Machefert@cea.fr



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:29 MET