0

Hi all. This has been bugging me for hours. I do a simple text book passing of a filehandle to a function and get a bundle of errors.

my func :

int appendVVmatrix(VVdouble &mat,ofstream& outF){
    if (outF.is_open()){
        for (int i=0; i<mat[0].size();i++) {
            for (int j=0; j<mat[0].size();j++) {
              char num[40];
              sprintf(num,"%f",mat[i][j]);
              outF << num << "\t";
            }
            outF << endl;
        }
    }
    else {
        cerr << " FILE Handle not initialized";
    }
    return 0;
}

In main I first :

ofstream outFS(outFileSq.c_str());

and then inside a for loop I call :

  appendVVmatrix(totalChanges,outFS);

The compile message :

g++ -c -O3 -Wall -Wno-sign-compare -I. -I../../libs/phylogeny -DLOG -ftemplate-depth-32  artificialDataCheck.cpp -o artificialDataCheck.doubleRep.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/ios_base.h: In copy constructor 'std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/ios_base.h:779: error: 'std::ios_base::ios_base(const std::ios_base&)' is private
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:55: error: within this context
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd: In copy constructor 'std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(const std::basic_ofstream<char, std::char_traits<char> >&)':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:92: note: synthesized method 'std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)' first required here 
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/streambuf: In copy constructor 'std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf(const std::basic_filebuf<char, std::char_traits<char> >&)':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/streambuf:781: error: 'std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits = std::char_traits<char>]' is private
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:86: error: within this context
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd: In copy constructor 'std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(const std::basic_ofstream<char, std::char_traits<char> >&)':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:92: note: synthesized method 'std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf(const std::basic_filebuf<char, std::char_traits<char> >&)' first required here 
artificialDataCheck.cpp: In function 'int main(int, char**)':
artificialDataCheck.cpp:132: note: synthesized method 'std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(const std::basic_ofstream<char, std::char_traits<char> >&)' first required here 
artificialDataCheck.cpp:132: error:   initializing argument 2 of 'int appendVVmatrix(VVdouble&, std::ofstream)'

Save the world !
Adam

Edited by mike_2000_17: Fixed formatting

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by adamomo
0

OOOOO....
found it . I forgot to update the .h file with the calls
to the filehandle by reference/
thanks any how
adam

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.