Skip to main content
gamedev.net
🔒 Locked

SDL function "is bool"

Started by Stromberg 1 reply 900+ views
Original Post
Stromberg
Stromberg
Why doesn't work this function?

class Check
{
    private:
    static bool is_bool(const SDL_Surface * object);
};

static bool Check::is_bool(const SDL_Surface * object)
{
    return !object;
}	

ERROR: Compiling: main.cpp H:\C++ Projekte\test_mixer\main.cpp:17: error: cannot declare member function `static bool Check::is_bool(const SDL_Surface*)' to have static linkage Thanks Stromberg
matthewbot
matthewbot
A little further explanation...

Static, along with const, has a ton of different meanings in C++. In the context of a class method declaration, static has the meaning that you're intending to use: Class method, as opposed to an instance method. But, in C++, class method modifiers, like static and virtual, aren't repeated when you actually define the class method. It just so happens that static has an additional meaning when applied to a function definition: static scope, or "Make this method only visible to this compilation unit." Since obviously a class method can't be visible to only a single compilation unit, the compiler quits.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.