1

だから私はいくつかの恐ろしいコードをデバッグしています. エラー

|22|undefined reference to `scene_manager::applySurface(int, int, SDL_Surface*, SDL_Surface*)'|

scene_manager.cpp

#include "scene_manager.h"

scene_manager::scene_manager(screen_manager* s){
    screen = s;
}

void scene_manager::add_object(object_manager* obj){
    if(game_objects.find(obj->get_name()) != game_objects.end()){
        game_objects[obj->get_name()] = obj;
    }
}

void applySurface(int x, int y, SDL_Surface* source, SDL_Surface* destination){
    SDL_Rect offset;
    offset.x = x;
    offset.y = y;
    SDL_BlitSurface(source, NULL, destination, &offset);
}

int scene_manager::render(){
    for(iter = game_objects.begin(); iter != game_objects.end();iter++){
        applySurface(game_objects.at(iter->first)->get_x(),game_objects.at(iter->first)->get_y(),game_objects.at(iter->first)->get_sprite(),screen->get_screen());
    }
    if(SDL_Flip(screen->get_screen()) == -1){
        return 1;
    }
    return 0;
}

scene_manager.h

#ifndef SCENE_MANAGER_H
#define SCENE_MANAGER_H
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "object_manager.h"
#include "screen_manager.h"
#include <map>
#include <string>

class scene_manager{
public:
    scene_manager();
    scene_manager(screen_manager* s);
    void add_object(object_manager* obj);
    int render();
private:
    std::map<std::string,object_manager*>game_objects;
    std::map<std::string,object_manager*>::iterator iter;
    screen_manager* screen;
    void applySurface(int x, int y, SDL_Surface* source, SDL_Surface* destination);
};
#endif
4

2 に答える 2

4

どうやら、この行

void applySurface(int x, int y, SDL_Surface* source, SDL_Surface* destination){

読みたい

void scene_manager::applySurface(int x, int y, SDL_Surface* source, SDL_Surface* destination){
于 2013-09-15T04:22:21.547 に答える
0

クラスの外で関数scope resolution operatorを定義するときに必要です。applySurface

void scene_manager::applySurface(int x, int y, SDL_Surface* source, SDL_Surface* destination){
     //^^^^^^^^^^^^^    
于 2013-09-15T04:23:44.700 に答える