IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Probleme vector ?


Sujet :

C++

  1. #1
    Membre averti
    Homme Profil pro
    ok
    Inscrit en
    Octobre 2018
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : ok

    Informations forums :
    Inscription : Octobre 2018
    Messages : 39
    Par défaut Probleme vector ?
    Bonjour j ai un probleme monumental avec mon code, le message d erreur est le suivant :
    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
    ||=== Build: Debug in nutriment (compiler: GNU GCC Compiler) ===| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\basic_ios.h||In instantiation of 'typename __gnu_cxx::__enable_if<(! std::__is_scalar<_Tp>::__value), void>::__type std::__fill_a(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = widget*; _Tp = widget; typename __gnu_cxx::__enable_if<(! std::__is_scalar<_Tp>::__value), void>::__type = void]':| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\stl_algobase.h|743|required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = widget*; _Tp = widget]'| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\vector.tcc|469|required from 'void std::vector<_Tp, _Alloc>::_M_fill_insert(std::vector<_Tp, _Alloc>::iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = widget; _Alloc = std::allocator<widget>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<widget*, std::vector<widget> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = widget*; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::value_type = widget]'| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\stl_vector.h|1073|required from 'void std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = widget; _Alloc = std::allocator<widget>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<widget*, std::vector<widget> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = widget*; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::value_type = widget]'| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\stl_vector.h|716|required from 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, std::vector<_Tp, _Alloc>::value_type) [with _Tp = widget; _Alloc = std::allocator<widget>; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::value_type = widget]'| 
    C:\Users\hp\Desktop\nutriment\src\interface.cpp|15|required from here| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\ios_base.h|852|error: 'std::ios_base& std::ios_base::operator=(const std::ios_base&)' is private| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\basic_ios.h|67|error: within this context| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\istream|58|note: synthesized method 'std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)' first required here | 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\istream|824|note: synthesized method 'std::basic_istream<char>& std::basic_istream<char>::operator=(const std::basic_istream<char>&)' first required here | 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\fstream|862|note: synthesized method 'std::basic_iostream<char>& std::basic_iostream<char>::operator=(const std::basic_iostream<char>&)' first required here | 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\streambuf|807|error: 'std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]' is private| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\fstream|72|error: within this context| 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\fstream|862|note: synthesized method 'std::basic_filebuf<char>& std::basic_filebuf<char>::operator=(const std::basic_filebuf<char>&)' first required here | 
    include\widget.h|11|note: synthesized method 'std::basic_fstream<char>& std::basic_fstream<char>::operator=(const std::basic_fstream<char>&)' first required here | 
    C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits\stl_algobase.h|697|note: synthesized method 'widget& widget::operator=(const widget&)' first required here | 
    ||=== Build finished: 4 error(s), 6 warning(s) (0 minute(s), 0 second(s)) ===|
    Je ne comprends pas trop d ou peut provenir l erreur, ca semble venir de la ligne 15 de cette methode qui ici est la ligne 3 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    int interface::dev()
    {
        m_widget.resize(3);
     
        for(int i = 0; i < 3; i++)
        {
            m_widget[i].dev(i);
        }
     
        return 0;
    }
    Mais je ne comprends rien aux erreurs qui sont affichées...

  2. #2
    Rédacteur/Modérateur


    Homme Profil pro
    Network game programmer
    Inscrit en
    Juin 2010
    Messages
    7 151
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Canada

    Informations professionnelles :
    Activité : Network game programmer

    Informations forums :
    Inscription : Juin 2010
    Messages : 7 151
    Billets dans le blog
    4
    Par défaut
    C'est quoi m_widget ?
    Pensez à consulter la FAQ ou les cours et tutoriels de la section C++.
    Un peu de programmation réseau ?
    Aucune aide via MP ne sera dispensée. Merci d'utiliser les forums prévus à cet effet.

  3. #3
    Membre averti
    Homme Profil pro
    ok
    Inscrit en
    Octobre 2018
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : ok

    Informations forums :
    Inscription : Octobre 2018
    Messages : 39
    Par défaut
    Donc voila le prototype de la classe interface:
    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
    #ifndef INTERFACE_H
    #define INTERFACE_H
     
    #include "SDL.h"
    #include "widget.h"
    #include "../misc.h"
    #include <vector>
     
    using namespace std;
     
    class interface
    {
        public:
            interface();
            ~interface();
     
            int dev();
     
            int INIT_INTERFACE(SDL_Window *window, SDL_Renderer *renderer);
     
     
     
        private:
            vector<widget> m_widget;
            int m_width, m_height, m_min_width, m_min_height;
            id m_screen[500][500];
    };
     
    #endif // INTERFACE_H
    Voici le prototype de la classe widget:
    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
    #ifndef WIDGET_H
    #define WIDGET_H
     
    #include "element.h"
    #include <vector>
    #include <iostream>
    #include <fstream>
     
    using namespace std;
     
    class widget
    {
        public:
            widget();
            ~widget();
     
            int dev(int j);
     
            int interact();
            int load();
            int save();
            int trash();
     
        private:
            string m_name;
            SDL_Rect m_body;
            int m_id;
     
            int m_nbelements;
            vector<element> m_elements;
     
            fstream m_file;
    };
     
    #endif // WIDGET_H
    Et sa déclaration:
    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
    46
    47
    48
    #include "widget.h"
     
    widget::widget()
    {
        //ctor
    }
     
    widget::~widget()
    {
        //dtor
    }
     
    int widget::dev(int j)
    {
        cout << "Set widget name " << j << " : ";
        cin >> m_name;
        cout << "Set widget width : ";
        cin >> m_body.w;
        cout << "Set widget height : ";
        cin >> m_body.h;
        cout << "Set widget x position : ";
        cin >> m_body.x;
        cout << "Set widget y position : ";
        cin >> m_body.y;
     
        cout << "How many elements in " << m_name << " widget : ";
        cin >> m_nbelements;
     
        m_elements.resize(m_nbelements);
     
        for(int i = 0; i < m_nbelements; i++)
        {
            m_elements[i].dev(i);
        }
     
        return 0;
    }
     
    int widget::load()
    {
     
        return 0;
    }
     
    int widget::save()
    {
        return 0;
    }

  4. #4
    Rédacteur/Modérateur


    Homme Profil pro
    Network game programmer
    Inscrit en
    Juin 2010
    Messages
    7 151
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Canada

    Informations professionnelles :
    Activité : Network game programmer

    Informations forums :
    Inscription : Juin 2010
    Messages : 7 151
    Billets dans le blog
    4
    Par défaut
    Dans widget tu as un fstream qui n'est pas copiable.
    Pensez à consulter la FAQ ou les cours et tutoriels de la section C++.
    Un peu de programmation réseau ?
    Aucune aide via MP ne sera dispensée. Merci d'utiliser les forums prévus à cet effet.

Discussions similaires

  1. Probleme avec la STL(vector) avec code C
    Par Benjy dans le forum SL & STL
    Réponses: 12
    Dernier message: 06/04/2006, 12h54
  2. Probleme avec parcours de stl::vector
    Par MDiabolo dans le forum SL & STL
    Réponses: 10
    Dernier message: 08/03/2006, 00h35
  3. Réponses: 15
    Dernier message: 20/09/2005, 09h54
  4. probleme de vector
    Par byvan dans le forum SL & STL
    Réponses: 22
    Dernier message: 17/09/2005, 18h56
  5. probleme avec vector
    Par venomelektro dans le forum SL & STL
    Réponses: 16
    Dernier message: 16/08/2004, 23h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo