Bonsoir,
J'ai essayé de suivre les explication sur l'algorithme de Huffman (histoire de m'instruire d'avantage et de me perfectionner en C++)...
j'ai voulu tester la cocherence d'une hierarchie de neuds, mais j'obtiens une erreur à la compilation:
-------------- Build: Debug in Huffman ---------------
Compiling: main.cpp
C:/MinGW/include/c++/3.2.3/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> >&)':
C:/MinGW/include/c++/3.2.3/bits/ios_base.h:424: `std::ios_base::ios_base(const
std::ios_base&)' is private
C:/Documents and Settings/U502136/Mes documents/C++/Huffman/main.cpp:13: within
this context
C:/Documents and Settings/U502136/Mes documents/C++/Huffman/main.cpp: In
function `int main()':
C:/Documents and Settings/U502136/Mes documents/C++/Huffman/main.cpp:13:
initializing argument 3 of `_OutputIter std::copy(_InputIter, _InputIter,
_OutputIter) [with _InputIter = std::_List_iterator<bool, bool&, bool*>,
_OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h: In function `_OutputIter
std::__copy(_InputIter, _InputIter, _OutputIter, std::input_iterator_tag)
[with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter =
std::basic_ostream<char, std::char_traits<char> >]':
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:266: instantiated from `_OutputIter std::__copy_aux2(_InputIter, _InputIter, _OutputIter, __true_type) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:303: instantiated from `_OutputIter std::__copy_ni2(_InputIter, _InputIter, _OutputIter, __false_type) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:323: instantiated from `_OutputIter std::__copy_ni1(_InputIter, _InputIter, _OutputIter, __false_type) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:349: instantiated from `_OutputIter std::copy(_InputIter, _InputIter, _OutputIter) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/Documents and Settings/U502136/Mes documents/C++/Huffman/main.cpp:13: instantiated from here
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:227: no match for `++
std::basic_ostream<char, std::char_traits<char> >&' operator
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:266: instantiated from `_OutputIter std::__copy_aux2(_InputIter, _InputIter, _OutputIter, __true_type) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:303: instantiated from `_OutputIter std::__copy_ni2(_InputIter, _InputIter, _OutputIter, __false_type) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:323: instantiated from `_OutputIter std::__copy_ni1(_InputIter, _InputIter, _OutputIter, __false_type) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:349: instantiated from `_OutputIter std::copy(_InputIter, _InputIter, _OutputIter) [with _InputIter = std::_List_iterator<bool, bool&, bool*>, _OutputIter = std::basic_ostream<char, std::char_traits<char> >]'
C:/Documents and Settings/U502136/Mes documents/C++/Huffman/main.cpp:13: instantiated from here
C:/MinGW/include/c++/3.2.3/bits/stl_algobase.h:228: no match for `*
std::basic_ostream<char, std::char_traits<char> >&' operator
Process terminated with status 1 (0 minutes, 1 seconds)
13 errors, 0 warnings
voici le code de ma fonction main (dans laquelle je teste mon algo):
Code c++ : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include "cnode.h"
#include <algorithm>
 
using namespace std;
using namespace huffman;
int main()
{
    cNode * node = new cNode();
    node->setCaractere('a');
    cNode node2 = new cNode(node);
    list<bool> &code = * node->getCode();
    copy(code.begin(), code.end(), cout);
    cout << endl;
    return 0;
}
Je trouve étrange qu'il soir impossible à un constructeur de faire appelle à une fonction privée d'une même classe. Je me doute donc que ces erreurs en cachent d'autres. A quel momentme suis-je planté?