2012-11-10 27 views
5

है, मुझे अपने क्लास ग्राफिक्स मैनेजर के साथ त्रुटियां मिल रही हैं।सी ++ त्रुटियां: 'grmanager' में सदस्य '...' के लिए अनुरोध जो गैर-वर्ग प्रकार 'ग्राफिक्स प्रबंधक'

GraphicsManager.cpp:

#include "C:\Users\Chris Uzzolina\Desktop\obj\include\GraphicsManager.h" 
#include <SDL.h> 
#include <string> 
GraphicsManager::GraphicsManager(int SCREEN_WIDTH, int SCREEN_HEIGHT, int SCREEN_BPP, std::string caption, SDL_Surface *screen) 
{ 

} 

GraphicsManager::~GraphicsManager() 
{ 
    //dtor 
} 
bool init(int SCREEN_WIDTH, int SCREEN_HEIGHT, int SCREEN_BPP, std::string caption, SDL_Surface *scr) 
{ 
    //Initialize all SDL subsystems 
    if(SDL_Init(SDL_INIT_EVERYTHING) == -1) 
    { 
     return false; 
    } 

    //Set up the screen 
    scr = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE); 

    //If there was an error in setting up the screen 
    if(scr == NULL) 
    { 
     return false; 
    } 

    //Set the window caption 
    SDL_WM_SetCaption("Event test", NULL); 

    //If everything initialized fine 
    return true; 
} 

SDL_Surface *load_image(std::string filename) 
{ 
    //Temporary storage for the image that's loaded 
    SDL_Surface* loadedImage = NULL; 

    //The optimized image that will be used 
    SDL_Surface* optimizedImage = NULL; 
    //Load the image 
    loadedImage = SDL_LoadBMP(filename.c_str()); 
    //If nothing went wrong in loading the image 
    if(loadedImage != NULL) 
    { 
     //Create an optimized image 
     optimizedImage = SDL_DisplayFormat(loadedImage); 

     //Free the old image 
     SDL_FreeSurface(loadedImage); 
    } 
    //Return the optimized image 
    return optimizedImage; 
} 

void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination) 
{ 
    //Make a temporary rectangle to hold the offsets 
    SDL_Rect offset; 

    //Give the offsets to the rectangle 
    offset.x = x; 
    offset.y = y; 
    //Blit the surface 
    SDL_BlitSurface(source, NULL, destination, &offset); 
} 

void clean_up(SDL_Surface *image) 
{ 
    //Free the image 
    SDL_FreeSurface(image); 
} 

void quit_sdl() 
{ 
    SDL_Quit(); 
} 

GraphicsManager.h:

#ifndef GRAPHICSMANAGER_H 
#define GRAPHICSMANAGER_H 
#include <string> 
#include<SDL.h> 
class GraphicsManager 
{ 
public: 
    GraphicsManager(); 
    GraphicsManager(int SCREEN_WIDTH, int SCREEN_HEIGHT, int SCREEN_BPP, std::string caption, SDL_Surface *screen); 
    virtual ~GraphicsManager(); 
    bool init(int SCREEN_WIDTH, int SCREEN_HEIGHT, int SCREEN_BPP, std::string caption, SDL_Surface *screen); 
    SDL_Surface *load_image(std::string filename); 
    void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination); 
    void clean_up(SDL_Surface *image); 
    void quit_sdl(); 
protected: 
private: 
}; 

#endif // GRAPHICSMANAGER_H 

SDLLesson01.cpp:

#include "SDL/SDL.h" 
#include "SDL/SDL_image.h" 
#include <string> 
#include "C:\Users\Chris Uzzolina\Desktop\obj\include\GraphicsManager.h" 

int SCREEN_WIDTH = 640; 
int SCREEN_HEIGHT = 480; 
int SCREEN_BPP = 32; 
SDL_Surface *message = NULL; 
SDL_Surface *background = NULL; 
SDL_Surface *screen = NULL; 
std::string caption = "THProject"; 
SDL_Event event; 

int main(int argc, char* args[]) 
{ 
    bool quit=false; 
    GraphicsManager grmanager(); 
    grmanager.init(SCREEN_WIDTH , SCREEN_HEIGHT , SCREEN_BPP , caption , screen); 
    message = grmanager.load_image("riku.bmp"); 
    background = grmanager.load_image("abc.bmp"); 
    grmanager.apply_surface(0, 0, background, screen); 
    grmanager.apply_surface(320, 0, background, screen); 
    grmanager.apply_surface(0, 240, background, screen); 
    grmanager.apply_surface(320, 240, background, screen); 
    grmanager.apply_surface(180, 140, message, screen); 
    if(SDL_Flip(screen) == -1) 
    { 
     return 1; 
    } 
    while(quit==false) 
    { 
     while(SDL_PollEvent(&event)) 
     { 
      if (event.type== SDL_QUIT) 
      { 
       quit=true; 
      } 
     } 
    } 
    grmanager.clean_up(message); 
    grmanager.clean_up(background); 
    grmanager.quit_sdl(); 
    return 0; 
} 

अब तक मैं इस साइट पर कई त्रुटियों के लिए चारों ओर खोज की है और मेरी नवीनतम त्रुटि के साथ फंस गया है। अगर कोई इस समस्या में कुछ अंतर्दृष्टि प्रदान कर सकता है तो इसकी सराहना की जाएगी। मैं विंडोज विस्टा चला रहा हूं और Code::Blocksmingw कंपाइलर और SDL पुस्तकालयों के साथ उपयोग कर रहा हूं। यहाँ निर्माण संदेशों है:

C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp||In function 'int SDL_main(int, char**)':| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|20|error: request for member 'init' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|21|error: request for member 'load_image' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|22|error: request for member 'load_image' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|23|error: request for member 'apply_surface' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|24|error: request for member 'apply_surface' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|25|error: request for member 'apply_surface' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|26|error: request for member 'apply_surface' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|27|error: request for member 'apply_surface' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|42|error: request for member 'clean_up' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|43|error: request for member 'clean_up' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
C:\Users\Chris Uzzolina\Desktop\obj\SDLLesson01.cpp|44|error: request for member 'quit_sdl' in 'grmanager', which is of non-class type 'GraphicsManager()'| 
||=== Build finished: 11 errors, 0 warnings ===| 
+4

अधिकांश वेक्सिंग पार्स फिर से हमला! – chris

+0

हू? थाटा का क्या मतलब है? – user1812530

+0

वहां एक स्पष्ट Google शब्द है;) – chris

उत्तर

0

अपने कोड में आप:

GraphicsManager grmanager(); 

आपको लगता है कि यह एक वर घोषणा GraphicsManager प्रकार के grmanager और डिफ़ॉल्ट निर्माता बुला मजबूर कर कहा जाता है। लेकिन यह वास्तव में एक ग्राफिक्स मैनेजर लौटने और कोई तर्क नहीं लेने वाले ग्रैनगर नामक एक समारोह घोषणा है। तो अपने संकलक

grmanager.Init(...) 
इसके लिए के रूप में

नहीं समझती, grmanager एक समारोह नाम है।

अपनी घोषणा को ग्राफिक्स प्रबंधक ग्रैनगर के साथ बदलने का प्रयास करें;

ठीक किया जाना चाहिए, अगर आप निर्माता के लिए तर्क उत्तीर्ण नहीं होते हैं, तो डिफ़ॉल्ट रूप से एक है कि कहा जाता है (जब तक आप एक अंधेरे आत्मा है और एक डिफ़ॉल्ट मान के साथ केवल तर्क के साथ केवल एक ही निर्माता बनाया) है

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^