splatJello

You can now splatter jello guts all over!

An interesting phenomenon occurred while finishing up section 9 of my C++ game development course.

Consider this code:

// Per class was: Pickup::Pickup(int type);

// But that gave me errors.

Pickup(int type);

// Prepare a new pickup

void setArena(IntRect arena);

The top line was how the instructor instructed us to write this code. However, when I ran it, I got this error during compilation:

alaskalinuxuser@alaskalinuxuser-OptiPlex-7010:~/Documents/c++/Cpp_training/JelloStorm$ ./build.sh
In file included from Pickup.cpp:2:0:
./Pickup.h:38:2: warning: extra qualification ‘Pickup::’ on member ‘Picku’ [-fpermissive]
Pickup::Pickup(int type);
^
In file included from JelloStorm.cpp:8:0:
./Pickup.h:38:2: warning: extra qualification ‘Pickup::’ on member ‘Picku’ [-fpermissive]
Pickup::Pickup(int type);

When I looked at the code, it was pointing to that line. I did a web search and came to an article that made this clearer. According to the writer on SO:

The qualification student:: is required only if you define the member functions outside the class, usually in .cpp file.

So we only need that if outside of the .h file we are creating it in. Odd. I’m not sure why the instructor put it that way, when you shouldn’t do that. But, fixing it was simple, as you can see in my above code.

And you can also check out the full commit at my GitLab! Be ready to pop some jello!

Linux – keep it simple.

Leave a Reply

Your email address will not be published.