Bonjour tout le monde,

Je débute en C/C++ (mais j'ai déjà fait du Java et du Python avant), j'arrive sur le forum et ne sais pas trop où poster. Si la discussion est au mauvais endroit, merci de la déplacer.
J'essaie de réaliser un Mahjong (ou Shangaï) en C++.
Pour l'instant j'ai réussi à faire fonctionner le jeu dans le terminal en créant les classes GrilleMahjong, Tulle et Partie en plus du main.
La grille du Mahjong hérite de multi_array<Tulle, 3> et Tulle est une classe avec pour seul attribut un entier valeur, j'utilise donc boost.
J'essaie maintenant de créer l'interface graphique avec Qt. Pour ce faire, j'ai créé les classes PlateauLayout et FenetreJeu.
PlateauLayout hérite de QGridLayout et me permet de placer mes Tulles (qui seront des QPushButton) selon un QGridLayout.
FenetreJeu hérite de QMainWindow et sera donc la fenêtre principale de mon jeu.
J'essaie maintenant de faire hériter Tulle de QPushButton, mais j'obtiens un drôle de message d'erreur ...
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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o FenetreJeu.o FenetreJeu.cpp
FenetreJeu.cpp: In constructor ‘FenetreJeu::FenetreJeu()’:
FenetreJeu.cpp:21: warning: unused variable ‘menuEdition’
FenetreJeu.cpp:22: warning: unused variable ‘menuAffichage’
                 from FenetreJeu.h:14,
                 from FenetreJeu.cpp:5:
/usr/include/qt4/QtGui/qpushbutton.h: In member function ‘Tulle& Tulle::operator=(const Tulle&)’:
In file included from GrilleMahjong.h:12,
Tulle.h:15:   instantiated from ‘OutputIter boost::detail::multi_array::copy_n(InputIter, Size, OutputIter) [with InputIter = Tulle*, Size = unsigned int, OutputIter = Tulle*]’
/usr/include/boost/multi_array.hpp:211:   instantiated from ‘boost::multi_array<T, NumDims, Allocator>::multi_array(const boost::multi_array<T, NumDims, Allocator>&) [with T = Tulle, unsigned int NumDims = 3u, Allocator = std::allocator<Tulle>]’
GrilleMahjong.h:16:   instantiated from here
/usr/include/qt4/QtGui/qpushbutton.h:113: error: ‘QPushButton& QPushButton::operator=(const QPushButton&)’ is private
Tulle.h:15: error: within this context
                 from /usr/include/boost/multi_array/base.hpp:25,
                 from /usr/include/boost/multi_array.hpp:21,
                 from GrilleMahjong.h:10,
                 from FenetreJeu.h:14,
                 from FenetreJeu.cpp:5:
/usr/include/boost/multi_array/algorithm.hpp: In function ‘OutputIter boost::detail::multi_array::copy_n(InputIter, Size, OutputIter) [with InputIter = Tulle*, Size = unsigned int, OutputIter = Tulle*]’:
In file included from /usr/include/boost/multi_array/storage_order.hpp:18,
/usr/include/boost/multi_array/algorithm.hpp:56: note: synthesized method ‘Tulle& Tulle::operator=(const Tulle&)’ first required here 
                 from FenetreJeu.h:14,
                 from FenetreJeu.cpp:5:
/usr/include/qt4/QtGui/qpushbutton.h: In copy constructor ‘Tulle::Tulle(const Tulle&)’:
In file included from GrilleMahjong.h:12,
Tulle.h:15:   instantiated from ‘void std::_Construct(_T1*, const _T2&) [with _T1 = Tulle, _T2 = Tulle]’
/usr/include/c++/4.4/bits/stl_uninitialized.h:187:   instantiated from ‘static void std::__uninitialized_fill_n<<anonymous> >::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = Tulle*, _Size = unsigned int, _Tp = Tulle, bool <anonymous> = false]’
/usr/include/c++/4.4/bits/stl_uninitialized.h:223:   instantiated from ‘void std::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = Tulle*, _Size = unsigned int, _Tp = Tulle]’
/usr/include/boost/multi_array.hpp:477:   instantiated from ‘void boost::multi_array<T, NumDims, Allocator>::allocate_space() [with T = Tulle, unsigned int NumDims = 3u, Allocator = std::allocator<Tulle>]’
/usr/include/boost/multi_array.hpp:210:   instantiated from ‘boost::multi_array<T, NumDims, Allocator>::multi_array(const boost::multi_array<T, NumDims, Allocator>&) [with T = Tulle, unsigned int NumDims = 3u, Allocator = std::allocator<Tulle>]’
GrilleMahjong.h:16:   instantiated from here
/usr/include/qt4/QtGui/qpushbutton.h:113: error: ‘QPushButton::QPushButton(const QPushButton&)’ is private
Tulle.h:15: error: within this context
                 from /usr/include/qt4/QtCore/qvector.h:52,
                 from /usr/include/qt4/QtGui/qbrush.h:47,
                 from /usr/include/qt4/QtGui/qpalette.h:47,
                 from /usr/include/qt4/QtGui/qwidget.h:48,
                 from /usr/include/qt4/QtGui/qcombobox.h:45,
                 from FenetreJeu.cpp:1:
/usr/include/c++/4.4/bits/stl_construct.h: In function ‘void std::_Construct(_T1*, const _T2&) [with _T1 = Tulle, _T2 = Tulle]’:
In file included from /usr/include/c++/4.4/vector:63,
/usr/include/c++/4.4/bits/stl_construct.h:74: note: synthesized method ‘Tulle::Tulle(const Tulle&)’ first required here 
make: *** [FenetreJeu.o] Erreur 1
BUILD FAILED (exit value 2, total time: 2s)
Ma classe Tulle est la suivante :

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
21
22
23
24
25
26
 
/* 
 * File:   Tulle.h
 *
 * Created on 11 avril 2010, 11:15
 */
 
#ifndef _TULLE_H
#define	_TULLE_H
 
#include <QtGui/QPushButton>
#include <QtGui/QApplication>
#include <QtGui/QWidget>
 
class Tulle :public QPushButton {
 
    int valeur;
 
    public:
        Tulle(void);
        Tulle(int);
        int getValeur(void);
        void setValeur(int);
};
 
#endif	/* _TULLE_H */
et le fichier cpp :

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
 
#include "Tulle.h"
 
Tulle::Tulle() {
    valeur=-1;
}
Tulle::Tulle(int i) {
    this->valeur=i;
}
int Tulle::getValeur(){
    return valeur;
}
void Tulle::setValeur(int i) {
    valeur = i;
}
Si j'enlève l'héritage, tout se passe bien (enfin ça compile et affiche des valeurs cohérentes).
Voyez-vous d'où peut venir le problème ou si j'ai fait une erreur de modélisation ?
Merci beaucoup