Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[C++] error: no matching function for call to '(...)'

Ostatnio zmodyfikowano 2015-01-24 16:45
Autor Wiadomość
PCS
Temat założony przez niniejszego użytkownika
[C++] error: no matching function for call to '(...)'
» 2015-01-24 12:57:48
Witam, mam problem taki jak w tytule tematu, poniżej zamieszczam kod funkcji, w której gdy podam jakikolwiek parametr wyskakuje właśnie ten błąd.

Game.cpp
C/C++
void Game::play()
{
    Snake snake;
    while( state == GAME )
    {
       
        while( window.pollEvent( event ) )
        {
            ////////////Sterowanie////////////////
            if( event.type == sf::Event::Closed || event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape )
            {
                state = MENU;
            }
           
            if( event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up )
            {
                snake.goUp( 1 );
               
            }
           
           
        }
        window.draw( sprite );
        window.display();
        window.clear();
       
    }
}

Snake.cpp:
C/C++
#include "Snake.h"

Snake::Snake()
{
   
    if( !texture.loadFromFile( "Postac.png" ) )
    {
        MessageBox( NULL, "Brak grafiki postaci!", "ERROR", NULL );
        return;
    }
    sprite.setTexture( texture );
   
}

Snake::~Snake()
{
   
}

void Snake::goUp( int liczba )
{
   
}

void Snake::goDown()
{
   
}

void Snake::goLeft()
{
   
}

void Snake::goRight()
{
   
}
Log kompilacji:


||=== Build: Debug in Snake (compiler: GNU GCC Compiler) ===|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp||In constructor 'Game::Game()':|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp|7|warning: passing NULL to non-pointer argument 4 of 'int MessageBoxA(HWND, LPCSTR, LPCSTR, UINT)' [-Wconversion-null]|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp||In member function 'void Game::runGame()':|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp|26|warning: enumeration value 'GAME_OVER' not handled in switch [-Wswitch]|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp|26|warning: enumeration value 'END' not handled in switch [-Wswitch]|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp||In member function 'void Game::menu()':|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp|63|warning: suggest parentheses around '&&' within '||' [-Wparentheses]|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp||In member function 'void Game::play()':|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp|108|warning: suggest parentheses around '&&' within '||' [-Wparentheses]|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp|115|error: no matching function for call to 'Snake::goUp(int)'|
D:\Piotrek\c++\Snake(M)\Snake\Game.cpp|115|note: candidate is:|
D:\Piotrek\c++\Snake(M)\Snake\Snake.h|19|note: void Snake::goUp()|
D:\Piotrek\c++\Snake(M)\Snake\Snake.h|19|note:   candidate expects 0 arguments, 1 provided|
||=== Build failed: 1 error(s), 5 warning(s) (0 minute(s), 0 second(s)) ===|

Dzięki z góry za pomoc.
P-125471
1aam2am1
» 2015-01-24 13:10:02
Pokaż plik snake.h
P-125473
PCS
Temat założony przez niniejszego użytkownika
» 2015-01-24 15:26:13
Proszę, Snake.h
C/C++
#include <SFML\Graphics.hpp>
#include <Windows.h>
#include <string>
#ifndef _Main_hpp
#define _Main_hpp
#include "_Main.h"
#endif

class Snake
    : public _Main
{
public:
   
    sf::Texture texture;
    sf::Sprite sprite;
   
    Snake();
    ~Snake();
    void goUp();
    void goDown();
    void goLeft();
    void goRight();
    int vx;
    int vy;
};
P-125478
PCS
Temat założony przez niniejszego użytkownika
» 2015-01-24 16:45:11
No tak, prosty błąd. Nie utworzyłem w definicji nowej zmiennej. Dzięki za pomoc.
P-125484
« 1 »
  Strona 1 z 1