Salut j'ai creer un patron de classe 'big' et j'ai essayé de surcharger l'operateur << mais ça plante bizarrement au linkage
Code : 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
17
18
19
20
template <typename U,typename I>
class big
{
U type1;
    I type2;
    public:
 
 
    big()
    {
    }
    ~big(){}
    friend ostream operator << (ostream &o, big<U,I>&);
};
template <typename U,typename I>
ostream operator << (ostream &o, const big<U,I>& bb)
{
    o<<bb.type1<<bb.type2;
    return o;
}
erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
main.cpp|99|warning: friend declaration `std::ostream operator<<(std::ostream&, big<U, I>&)' declares a non-template function|
 
main.cpp|99|warning: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) -Wno-non-template-friend disables this warning|
 
.objs\main.o:main.cpp:(.text+0x1f2)||undefined reference to `operator<<(std::ostream&, big<int, int>&)'|