为什么把SDL里的Screen方法转化成类就会显示这个呀? 我后来照着源码打了一遍,然后又显示第二个问题。。求解
#ifndef SCREEN_H
#define SCREEN_H
#include <SDL2/SDL.h>
class ScreenSurface
{
private:
static int screenNum;
int width;
int height;
int bpp;
Uint32 flags;
SDL_Surface* pScreen;
public:
ScreenSurface();
ScreenSurface(int w, int h, int b = 0, Uint32 f = 0);
~ScreenSurface();
SDL_Surface* point() const;
bool flip() const;
};
#endif
int ScreenSurface::screenNum = 0;
ScreenSurface::ScreenSurface():
width(640), height(480), bpp(32), flags(0)
{
if ( screenNum > 0 )
throw "DONOT create more than ONE screen!";
if ( SDL_Init(SDL_INIT_VIDEO < 0 ) )
throw SDL_GetError();
pScreen = SDL_SetVideoMode(width, height, bpp, flags);
screenNum++;
}
ScreenSurface::ScreenSurface(int w, int h, int b, Uint32 f):
width(w), height(h), bpp(b), flags(f)
{
if ( screenNum > 0 )
throw "DONOT create more than ONE screen!";
if ( SDL_Init(SDL_INIT_VIDEO < 0 ) )
throw SDL_GetError();
pScreen = SDL_SetVideoMode(width, height, bpp, flags);
screenNum++;
}
ScreenSurface::~ScreenSurface()
{
SDL_Quit();
}
SDL_Surface* ScreenSurface::point() const
{
return pScreen;
}
bool ScreenSurface::flip() const
{
if ( SDL_Flip(pScreen) < 0 )
return false;
else return true;
}
#include"screen.h"
#include<iostream>
int main(int argc,char * args[])
{
using namespace std;
ScreenSurface am;
return 0;
}


#ifndef SCREEN_H
#define SCREEN_H
#include <SDL2/SDL.h>
class ScreenSurface
{
private:
static int screenNum;
int width;
int height;
int bpp;
Uint32 flags;
SDL_Surface* pScreen;
public:
ScreenSurface();
ScreenSurface(int w, int h, int b = 0, Uint32 f = 0);
~ScreenSurface();
SDL_Surface* point() const;
bool flip() const;
};
#endif
int ScreenSurface::screenNum = 0;
ScreenSurface::ScreenSurface():
width(640), height(480), bpp(32), flags(0)
{
if ( screenNum > 0 )
throw "DONOT create more than ONE screen!";
if ( SDL_Init(SDL_INIT_VIDEO < 0 ) )
throw SDL_GetError();
pScreen = SDL_SetVideoMode(width, height, bpp, flags);
screenNum++;
}
ScreenSurface::ScreenSurface(int w, int h, int b, Uint32 f):
width(w), height(h), bpp(b), flags(f)
{
if ( screenNum > 0 )
throw "DONOT create more than ONE screen!";
if ( SDL_Init(SDL_INIT_VIDEO < 0 ) )
throw SDL_GetError();
pScreen = SDL_SetVideoMode(width, height, bpp, flags);
screenNum++;
}
ScreenSurface::~ScreenSurface()
{
SDL_Quit();
}
SDL_Surface* ScreenSurface::point() const
{
return pScreen;
}
bool ScreenSurface::flip() const
{
if ( SDL_Flip(pScreen) < 0 )
return false;
else return true;
}
#include"screen.h"
#include<iostream>
int main(int argc,char * args[])
{
using namespace std;
ScreenSurface am;
return 0;
}


