球員類: -「不具有類類型」 錯誤
#ifndef PLAYER_H
#define PLAYER_H
class Player : public sf::Drawable, sf::Transformable
{
public:
Player(int indexWd, int indexHi);
bool load();
};
遊戲類: -
#ifndef GAME_H
#define GAME_H
#include "Player.h"
#include <SFML/Graphics.hpp>
class Game
{
public:
Game();
Player player(int indWd, int indHi);
void load();
};
#endif // GAME_H
遊戲裏面的cpp文件: -
#include "Game.h"
Game::Game()
{
}
void Game::load()
{
player(world.getIndexWd(), world.getIndexHi());
player.load(); //gives error
}
at player.load()在上述方法中,編譯器給出以下錯誤: -
error: '((Game*)this)->Game::player' does not have class type|
爲什麼會發生此錯誤?
player = Player(world.getIndexWd(),world.getIndexHi()); player.load(); 我在加載函數中做了這個,但它不工作。它給出了以下錯誤: - 錯誤:無效使用成員函數(你忘了'()'?) – arandomguy
@rkj:你是否也將'player'更改爲變量,就像我說的那樣?當然,假設它應該是一個變量。我只是在猜測,因爲你發佈的代碼沒有多大意義。 –
是的,我把它改成Player player ;.但現在它給這個錯誤: - 錯誤:沒有匹配函數調用'Player :: Player()' – arandomguy