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 :

Classe héritée ne trouve pas la méthode de ma classe mère.


Sujet :

C++

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Invité
    Invité(e)
    Par défaut Classe héritée ne trouve pas la méthode de ma classe mère.
    Salut!
    J'ai une classe dans un namespace SDLWindow :
    Code cpp : 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
    49
    50
    51
    52
     
    #include "../../../include/odfaeg/Graphics/sdlWindow.hpp"
    namespace odfaeg {
        namespace window {
            SDLWindow::SDLWindow(unsigned int width, unsigned int height, std::string title) {
                create(width, height,title);
            }
            void SDLWindow::create(unsigned int width, unsigned int height, std::string title) {
                window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_UNDEFINED,
                                          SDL_WINDOWPOS_UNDEFINED,
                                          width,
                                          height,
                                          SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
                this->width = width;
                this->height = height;
            }
            void SDLWindow::initSDL() {
                if (SDL_Init(SDL_INIT_VIDEO) != 0 )
                {
                    fprintf(stdout,"Échec de l'initialisation de la SDL (%s)\n",SDL_GetError());
                    return -1;
                }
            }
            void SDLWindow::onCreate() {
     
            }
            void SDLWindow::onResize() {
     
            }
            void SDLWindow::setPosition(unsigned int x, unsigned int y) {
                SDL_SetWindowPosition(window, x, y);
            }
            bool SDLWindow::pollEvent(SDL_Event event) {
            }
            bool SDLWindow::isOpen() {
                return window != nullptr;
            }
            void SDLWindow::close() {
                SDL_DestroyWindow(window);
                window = nullptr;
            }
            void SDLWindow::display() {
                SDL_GL_SwapWindow(window);
            }
            SDL_Window* SDLWindow::getWindow() {
                return window;
            }
            SDLWindow::~SDLWindow() {
                SDL_DestroyWindow(window);
            }
        }
    }

    Et une autre classe dans un autre namespace qui hérite de SDLWindow :
    Code cpp : 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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
     
    #include "../../../include/odfaeg/Graphics/sdlRenderWindow.hpp"
    #include "glCheck.h"
    namespace odfaeg {
        namespace graphic {
            using namespace sf;
            SDLRenderWindow::SDLRenderWindow(unsigned int width, unsigned int height, const std::string& title, const sf::ContextSettings& settings)
            {
                this->settings = settings;
                activated = false;
                create(width, height, title);
            }
            bool SDLRenderWindow::activate(bool active) {
                if (active && !activated) {
                    if(SDL_GL_MakeCurrent(window::SDLWindow::getWindow(), context)) {
                        return false;
                    } else {
                        activated = true;
                        return true;
                    }
                } else if (!active && activated) {
                    if(SDL_GL_MakeCurrent(window::SDLWindow::getWindow(), nullptr)) {
                        return false;
                    } else {
                        activated = false;
                        return true;
                    }
                }
                return true;
            }
            bool SDLRenderWindow::isActive() {
                return activated;
            }
            bool SDLRenderWindow::isUsingDepthTest() const {
                return useDepthTest;
            }
            void SDLRenderWindow::onCreate() {
                SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, settings.majorVersion);
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, settings.minorVersion);
                SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, settings.stencilBits);
                SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, settings.depthBits);
                SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (settings.antialiasingLevel > 0) ? 1 : 0);
                SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, settings.antialiasingLevel);
                context = SDL_GL_CreateContext(window);
                priv::ensureGlewInit();
                /*glewExperimental = GL_TRUE;
                GLenum status = glewInit();
                if (status == GLEW_OK)
                {
                    std::cout<<"Glew initialized!"<<std::endl;
                }
                else
                {
                    err() << "Failed to initialize GLEW, " << glewGetErrorString(status) << std::endl;
                }*/
                // Just initialize the render target part
                RenderTarget::initialize();
            }
            SDLRenderWindow::~SDLRenderWindow() {
                SDL_GL_DeleteContext(context);
            }
        }
    }

    Le problème c'est que le compilateur me dit qu'il ne trouve pas la méthode getWindow() de la classe mère :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    /home/laurent/Développement/Projets-c++/ODFAEG/src/odfaeg/Graphics/sdlRenderWindow.cpp|14|error: ‘getWindow’ is not a member of ‘odfaeg::window::SDLWindow’|
    Est ce que la classe mère doit être dans le même namespace que la classe fille ?
    Dernière modification par Invité ; 04/01/2019 à 15h19.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 20/06/2012, 09h27
  2. Je ne trouve pas les méthodes coté client
    Par Invité dans le forum Services Web
    Réponses: 1
    Dernier message: 24/02/2011, 18h15
  3. (macosX,eclipse 3.4) classe JPA non trouvée pas un EJB
    Par olivier57b dans le forum Glassfish et Payara
    Réponses: 16
    Dernier message: 17/01/2009, 22h32
  4. Réponses: 2
    Dernier message: 31/07/2007, 14h12
  5. [JNI] Java ne trouve pas mes méthodes natives
    Par carotte31 dans le forum Entrée/Sortie
    Réponses: 5
    Dernier message: 14/06/2006, 21h47

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